0

I need to call one webservice and I need to pass one string parameter within it and get response from it. Url look like http://192.168.200.131:8085/MasterService.asmx/SignUpExistingUser where SignUpExistingUser is parameter and I need to pass it one parameter called ArgMobileNo as string.

What I have tried so far :

 try
            {
                using (var client = new HttpClient())
                {
                    dynamic returnValue;
                    client.BaseAddress = new Uri("http://192.168.200.131:8085/");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    HttpResponseMessage response = await client.GetAsync("/MasterService.asmx/SignUpExistingUser?ArgMobileNo=9898989898");  // <-- HERE GETS ERROR
                    response.EnsureSuccessStatusCode();
                    returnValue = JsonConvert.DeserializeObject<string>(((HttpResponseMessage)response).Content.ReadAsStringAsync().Result);
                }
                // return returnValue;
            }
            catch (Exception e)
            {
                throw (e);
            }
Nikunj Patel
  • 249
  • 3
  • 13
  • Did you try option of creating service proxy? If you are planning to use HttpClient then you need to post soap envelope containing your inputs. – Pankaj Kapare Jul 29 '17 at 11:19
  • @PankajKapare, Thanks for your reply. I am planning do use `HttpClient` but its not working at all ! – Nikunj Patel Jul 29 '17 at 12:07
  • If your service is not scriptenabled then you need to post soap envelope (see this https://stackoverflow.com/questions/16584262/using-httpclient-with-asmx-in-c-sharp). If its scriptenabled then you need something like this https://stackoverflow.com/questions/42745264/how-to-make-a-http-request-using-c-sharp-to-asmx-web-method-which-is-returning-c – Pankaj Kapare Jul 29 '17 at 12:17

0 Answers0