Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 74,098 times

Contents

Related Categories

XML SOAP - The Client

The Client

In traditional VB terms, our request to the GetSalesTax function described above, would be something such as:

dblSalesTax = GetSalesTax(100)

Returning a value of $4.

If the GetSalesTax function was contained within an external object, such as an MTS server, then the call would need to reference the server DLL:

Dim objTax As New CTaxCalc

dblSalesTax = objTax.GetSalesTax(100)

In a SOAP system the call is little different, only the request is formatted as an XML document, which is passed up to the server. The appropriate document contains the same details as the MTS call –a method to call, and the parameter name and value.

<GetSalesTax>
    <SalesTotal>100</SalesTotal>
<GetSalesTax>

In order to ensure that the server can correctly identify and decrypt this method call, it is wrapped up in a larger document, called a SOAP envelope, which references the universal name-space of the SOAP envelope standard.

<SOAP:Envelope xmlns:SOAP="urn:schemas-xmlsoap-org:soap.v1">
    <SOAP:Header></SOAP:Header>
    <SOAP:Body>
        <GetSalesTax>
            <SalesTotal>100</SalesTotal>
        <GetSalesTax>
    </SOAP:Body>
</SOAP:Envelope>

Finally, to complete our SOAP request document, we will add a name-space reference to our method call, which points to the object which contains the method – the equivalent of the object declaration (Dim objTax As New CTaxCalc) in our MTS method call.

<SOAP:Envelope xmlns:SOAP="urn:schemas-xmlsoap-org:soap.v1">
    <SOAP:Header></SOAP:Header>
    <SOAP:Body>
        <m:GetSalesTax xmlns:m="urn:myserver/soap:TaxCalc">
            <SalesTotal>100</SalesTotal>
        </m:GetSalesTax>
    </SOAP:Body>
</SOAP:Envelope>

Now that we have built our SOAP request document, we are ready to send it to the server. The request is a simple HTTP post - just like posting a web form in your internet browser. Of course, your internet browser masks all the complexity of sending a form to a server; and in the longer-term .NET will mask this process from your VB code too. But for now, we need to do the job ourselves; and I have been using Microsoft's XML HTTP Request object to give me a helping hand. (The XMLHTTPRequest is an object within the MSXML class library (MSXML.DLL), and it comes with IE5.) Assuming that strEnvelope contains the XML document described above, the request is formatted thus:

Dim objHTTP As New MSXML.XMLHTTPRequest
Dim strEnvelope As String

'Set up to post to our localhost server
objHTTP.open "post", "http://localhost/soap/soap.asp"

'Set a standard SOAP/ XML header for the content-type
objHTTP.setRequestHeader "Content-Type", "text/xml"

'Set a header for the method to be called
objHTTP.setRequestHeader "SOAPMethodName", _
    "urn:myserver/soap:TaxCalc#GetSalesTax"

'Make the SOAP call
objHTTP.send strEnvelope

'Get the return value
strReturn = objHTTP.responseBody

Now that we have sent our request, we move to the server, to see how we set up a SOAP service to listen and respond to our calls.

Comments

  • Posted by kpma_l on 19 May 2004

    [quote][1]Posted by [b]kpma_l[/b] on 19 May 2004 04:05 PM[/1]
    I tried to copy the the code and add references to VB project and run the VB app. but get runtime error at the DOMDocument object accesin...

  • getting Runtime error 91 - object or with block va

    Posted by kpma_l on 19 May 2004

    I tried to copy the the code and add references to VB project and run the VB app. but get runtime error at the DOMDocument object accesing a single node.

    Run time error 91.

    MSXML2 and MTS Admin ...

  • WebServices

    Posted by shirikok on 01 Apr 2004

    In .NET web services; How to monitor from where (mostly his/her web site URL but not his/her machine IP) requester is consuming the web service? Techies, [b]'HTTP_REFERER' [/b] and [b]'URLReferrer'[/b...

  • XML SOAP - ASP

    Posted by shirikok on 01 Apr 2004

    Great work by ComponentSource and they have very well explained VB 6.0 client and access to web service. I have a question here. How to monitor from where (mostly his/her web site URL not his/her mac...

  • got the same ???????+???...

    Posted by synapticdata on 20 Nov 2003

    if anyone knows the meaning of this, i could use the feedback. my hunch is, that the SOAP server is not configured to handle the request properly. but i dunno... =)