I am learning asp.net, and trying to understand in consuming a webservice. I am using the following wsdl file
http://www.webservicex.net/uszip.asmx?WSDL
I am using a textbox to enter the zipcode, added the wsdl in the web reference , and am using C# to retrieve data. The structure of the data is as follows:
http://www.webservicex.net/uszip.asmx/GetInfoByZIP
I am not able to understand on how to display the results on a webpage. The following code is what I have until now..
protected void Button1_Click(object sender, EventArgs e)
{
USZip s1 = new USZip();
var input = zipcode.Text.ToString();
String result = s1.GetInfoByZIP(input);
}
It would be great if anyone can give me helpful pointers
Thanks a lot
Hover over the call to GetInfoByZIP and you should see that it returns an XmlNode. Since there is no implicit conversion from an XmlNode to a string, then you should not be able to assign the result directly to a string. To get the string value, call the XmlNode property OuterXml, like so (make sure you have a multi-line text control):
Per the WSDL, the call returns a GetInfoByZipResult, which can contain any XML (with no further specification in the WSDL). The XML I get looks like the XML below. So, if you want to get to the name of the City, State, etc., you will need to parse the XML.