AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
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?

 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > VB.NET and XML

Topic: VB.NET



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:

http://localhost/MyWebApp/MyWebService.asmx?WSDL

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()

Hope this helps!

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.