About Chris Expertise I can answer pretty much any question relating to VB.NET and its use in a Windows environment. I specialize in ASP.NET web development and MSSQL database access.
Experience I have over 5 years of industry experience using VB.NET and other .NET technologies for web and database development.
Education/Credentials I have some college education, but does it really matter in this field of work?
Expert: Chris Date: 9/7/2007 Subject: VB.NET and XML
Question A function in a web service returns some data in XML format. My question is: How should I declare a function in my
program to get that XML. I did some tests but they all fail. Here is one:
webservice function:
Public Function givemedata() as xmlDocument
Dim test as new xmldocument
'Here we add some data
Return test
End Func
My program function:
Sub GetData() As xmlDocument
Dim Data As New xmlDocument
Data = webservice.givemedata()
End Sub
Answer Your best bet is to use Visual Studio to auto-generate this code for you. It's a very complicated procedure to do it yourself.
To do it from within Visual Studio, open your project (or create one), right-click the project, and pick Add Web Reference. In the URL box, enter the URL to your web service, followed by the querystring ?WSDL. For example:
Click Go or press enter, and you should see a nicely formatted description of your web service's interface (the functions you've chosen to expose with a <WebService()> directive) on the left. On the right, you're given a chance to rename the class that will be auto-generated for this web service, or the "Web reference name". Rename it if you want, then click Add Reference.
Now, you should be able to call your web service with the class name you chose, for example:
Dim strXML as String = localhostWebService.givemedata()