I need help with SOAP client

Posted on 2006-05-02
Last Modified: 2008-01-09
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!! 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
Question by:FirePits
    LVL 60

    Accepted Solution

    Hi FirePits,

    One thing you can do is download Altova XMLSpy enterprise (
    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 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

    LVL 1

    Author Comment

    Thank you Gertone, this helped tremendously!
    LVL 26

    Expert Comment

    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
    LVL 1

    Author Comment

    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
    LVL 26

    Expert Comment

    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

    Which version of Visual Studio are you using?

    Mike Sharp
    LVL 1

    Author Comment

    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?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    Title # Comments Views Activity
    jaxb jaxp sax dom 7 41
    Intellij adding new line in xml 3 55
    XSLT Assistance 9 38 XML Read all nodes and 4 49
    The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now