Using A WSDL To Get Data?

Hey everyone

I have a WSDL file that I am meant to use in order to pull data back to my application.  I have added the reference, and can see the methods that I think I should use... but how exactly do I use them?  I'm not sure how to extract anything from the response method, or even how to send the request.

All help is greatly appreciated
LVL 15
angus_young_acdcAsked:
Who is Participating?
 
ImperdonatoConnect With a Mentor Commented:
Suppose the name of the reference that you added is "Ref_WebSvc"
Also, suppose the WSDL exposes a class named "AdditionHelper", which has a method "int  Add(int a, int b)..."

The C# code for this will be something like this...

Hope that helps.

using Ref_WebSvc;
...
...
...
...
 
public void TestCaller()
{
    int param1 = 5;
    int param2 = 10;
    Ref_WebSvc.AdditionHelper helper = new Ref_WebSvc.AdditionHelper();
    int retVal = helper.Add(param1, param2);
    .....
    ....
}

Open in new window

0
 
DhaestConnect With a Mentor Commented:
The wsdl is just a description of the webmethods

WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). WSDL is extensible to allow description of endpoints and their messages regardless of what message formats or network protocols are used to communicate, however, the only bindings described in this document describe how to use WSDL in conjunction with SOAP 1.1, HTTP GET/POST, and MIME.

http://www.w3.org/TR/wsdl
0
 
angus_young_acdcAuthor Commented:
How can I actually make a call to get data then?  I can only seem to generate an exception about not setting a security header.
0
 
nost2Connect With a Mentor Commented:
If you have never tried using a web service before I suggest you write a small test application. Just to get an idea of what web services is about. In Visual Studio, add a web reference to: http://wslite.strikeiron.com/censusinfolite01/CensusInfoLite.asmx?WSDL
This code will call a method of the web service:

            com.strikeiron.wslite.CensusInfoLite cl = new WindowsApplication2005C.com.strikeiron.wslite.CensusInfoLite();
            com.strikeiron.wslite.CensusOutput co = cl.GetCensusInfoForZIPCode("27513");

0
 
DhaestConnect With a Mentor Commented:
Calling Webservices from ASP.NET: Example Google Web Service
http://www.paragoncorporation.com/ArticleDetail.aspx?ArticleID=13
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.