C# ASP.Net adding online web service -
i trying add online soap web service web application in visual studio. tried several tutorials of tutorials focus on creating server on local host.
in web application, want countries web service using following url. http://www.webservicex.net/country.asmx?op=getcountries
it provides following soap request , response.
request
post /country.asmx http/1.1 host: www.webservicex.net content-type: application/soap+xml; charset=utf-8 content-length: length <?xml version="1.0" encoding="utf-8"?> <soap12:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:body> <getcountries xmlns="http://www.webservicex.net" /> </soap12:body> </soap12:envelope>
response
http/1.1 200 ok content-type: application/soap+xml; charset=utf-8 content-length: length <?xml version="1.0" encoding="utf-8"?> <soap12:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:body> <getcountriesresponse xmlns="http://www.webservicex.net"> <getcountriesresult>string</getcountriesresult> </getcountriesresponse> </soap12:body> </soap12:envelope>
how added web service reference is,
in visual studio, clicked in project -> add -> service reference -> advanced tab -> add web reference -> entered url of web service(http://www.webservicex.net/country.asmx).
my problem how countries web service. tries several methods, no success. how call service asp file.
you instantiate class built , call member function:
protected void btn_click(object sender, eventargs e) { servicereference1.countrysoapclient client = new servicereference1.countrysoapclient("countrysoap12"); string countries = client.getcountries(); }
cool, string returned looks xml exported dataset. should able read new dataset....and bind something.
Comments
Post a Comment