I need help with SOAP client

Ok, so I want to tap into a web service...I have the WSDL, and know the format my XML needs to be in. I just can't figure out the client portion in vb.net!! If someone could provide me with a really simple client to send the XML via SOAP and accept the return XML, that would be great! Not sure if it matters, but I am sending the request over a SSL connection.

One thing I forgot to mention.....when I go to view the WSDL I have to enter a user/pass, does that mean that somewhere in the SOAP request I need to include my username and password?

Thanks in advance
Who is Participating?
Geert BormansConnect With a Mentor Information ArchitectCommented:
Hi FirePits,

One thing you can do is download Altova XMLSpy enterprise (www.altova.com)
that is a good tool to explore how the soap envelopes are created

- start XMLSpy
    + in the SOAP menu pick "Create new soap request"
    + in "enter the WSDL..." put the wsdl address: "http://www...."
    + press OK
    + you will get your operations listed
    + double click on the operation you want to use
    + you will now see a soap XML file... that is the mock-up of what you have to send to the service
    + edit the XML, and fill in the parameters
    + in the SOAP menu "send request to server"
    + you see a soap return message
    + you just did your first soap test
    + for doing this in JavaScript, you need to know the soap message you sent and the return message (to get the info from)
       you also need the "action"
    + in the SOAP menu: "change request parameters"
    + copy what is under soapaction in the http soapaction header when required (in your javascript later)

in this story, replace JavaScript with your language of choice

please note that vb.net likely has some controls to make this easier

the password/username are likely in the header of your soap request... XML Spy will show you where to add them

FirePitsAuthor Commented:
Thank you Gertone, this helped tremendously!
In VB.NET (or any other .NET language, for that matter) it's very easy to connect to a web service.  You don't have to worry about SOAP or any of that.  There are at least two ways to do this.  

Method 1

There is a utility in the .NET SDK that you can download from Microsoft that will generate the proxy code you'll need to interact with the web service.  It's called WebServiceUtil.exe.  Among other things, it can generate the proxy code, using a command line like:

WebServiceUtil /c:proxy /pa:http://yourDomain/someFolder/yourWebService.asmx?wsdl /l:visualbasic /n:Namespace

This will create a compilable file, like MyWebService.vb

You compile this, and then add the DLL as a reference to your VB project.  Treat it like any other object--you simply call it's methods to invoke the web service.

Method 2
In your project, add a Web Reference.  This generates the proxy code right in your project.  For example, in a recent MS Content Management Server (MCMS) site that I build, I used SharePoint to provide search services.  I make a web service call to the SharePoint search service at http://ServerName/_vti_bin/search.asmx

When I add the web reference, I get a bunch of proxy code in a file called Reference.cs.  In that file there is this string method:

                RequestNamespace="urn:Microsoft.Search", ResponseNamespace="urn:Microsoft.Search",
        public string Query(string queryXml) {
            object[] results = this.Invoke("Query", new object[] {
            return ((string)(results[0]));

The proxy stub handles all the conversions to SOAP and all that, so I call the web service simply by

results = myQuery.Query(strQuery);

Ok, its a bit more complicated, but not by much.  You set things like credentials and timeouts and such like this:

// Create the secondary web service query proxy
QueryService querySecondary = new QueryService();
querySecondary.Url = sUrl;
querySecondary.Timeout = statusTimeout;
NetworkCredential myCredentialsSecondary = new NetworkCredential("","","");
myCredentialsSecondary.Domain = sDomain;
myCredentialsSecondary.UserName = sUser;
myCredentialsSecondary.Password = sPass;
querySecondary.Credentials = myCredentialsSecondary;
      spsSecStatus = querySecondary.Status();
catch (Exception SpsSecEx)
      bSearchError = true;
      sbResults.Append("Secondary SPS Server Status: " + spsSecStatus + "<br>");

Really, in .NET, it's a piece of cake.  There are a number of examples of this in the various SDKs and articles in MSDN.

Mike Sharp
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

FirePitsAuthor Commented:
Thanks Mike,
So, I added the web reference in my project. However, it didn't produce a class as expected. Once I added the web reference, the only files created were a .disco, .discomap and wsdl file. Am I doing something wrong??

Thanks again for your help
It's a bit hidden.  Expand the map, and you should see it there.  In my project, adding a web reference adds:


The code is buried under Reference.map.

Which version of Visual Studio are you using?

Mike Sharp
FirePitsAuthor Commented:
Related to my question, can anyone help with this problem?

I have created a proxy class using the wsdl.exe tool. There are certain functions in the proxy class that have a return value, and I have successfully output those return values. However, there is one particular function that I will need to access 90% of the time that does not have a return value. What I am trying to figure out is how to access the response xml from that function request, or access the object that I'm assuming the proxy class creates with the response.

I have been using a program called XMLSpy to test my requests, in pure xml not using a proxy class, and I select the same function that I am using with my proxy class, but XMLSpy shows me the response xml from my request. I am not sure how XMLSpy is accessing the response xml, but at least I know it's receiving it.

I searched the proxy class for a Deserialize() method, but wasn't able to find one?
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.