Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic Soap VB6 to ASP and Back

Status
Not open for further replies.

bennynye

Programmer
Feb 8, 2002
10
0
0
US
I am running a simple SOAP example that I see everywhere on the web. The example should pass a parameter to an ASP page which in turn responds. There are only parts to the example. The VB part is as follows:

Code:
Sub Main()
  Dim objhttp As New MSXML.XMLhttpRequest
  Dim strEnvelope As String
  Dim strReturn As String
  Dim objReturn As New MSXML.DOMDocument
  Dim dblTax As Double
  Dim strQuery As String
  
  'Create the SOAP Envelope
  strEnvelope = _
    &quot;<soap:envelope xmlns:soap=&quot;&quot;urn:schemas-xmlsoap-org:soap.v1&quot;&quot;>&quot; & _
    &quot;<soap:header></soap:header>&quot; & _
    &quot;<soap:body>&quot; & _
    &quot;<m:getsalestax xmlns:m=&quot;&quot;urn:myserver/soap:TaxCalculator&quot;&quot;>&quot; & _
    &quot;<salestotal>100</salestotal>&quot; & _
    &quot;</m:getsalestax>&quot; & _
    &quot;</soap:body>&quot; & _
    &quot;</soap:envelope>&quot;
  
  'Set up to post to our local server
  objhttp.open &quot;post&quot;, &quot;[URL unfurl="true"]http://www.assetmarketingsystems.net/bnye/UpdateApplication.asp&quot;,[/URL] False
  
  'Set a standard SOAP/ XML header for the content-type
  objhttp.setRequestHeader &quot;Content-Type&quot;, &quot;text/xml&quot;
  
  'Set a header for the method to be called
  objhttp.setRequestHeader &quot;SOAPMethodName&quot;, _
    &quot;urn:myserver/soap:TaxCalculator#GetSalesTax&quot;
  
  'Make the SOAP call
  objhttp.send strEnvelope
  
  'Get the return envelope
  strReturn = objhttp.responseText
  
  'Load the return envelope into a DOM
  objReturn.loadXML strReturn
  
  'Query the return envelope
  strQuery = _
    &quot;SOAP:Envelope/SOAP:Body/m:GetSalesTaxResponse/SalesTax&quot;
  dblTax = objReturn.selectSingleNode(strQuery).Text
  
  Debug.Print dblTax
End Sub

The ASP page is as follows:

Code:
<%
Dim strQuery
Dim varSalesTax
Dim varSalesTotal
Dim strTemp
Dim objReq

'Server.CreateObject(&quot;Microsoft.XMLDOM&quot;)
Set objReq = Server.CreateObject(&quot;MSXML2.DOMDocument.4.0&quot;)

'Load the request into XML DOM
objReq.Load Request


'Query the DOM for the input parameter
strQuery = &quot;SOAP:Envelope/SOAP:Body/m:GetSalesTax/SalesTotal&quot;

varSalesTotal = objReq.SelectSingleNode(strQuery).Text

'Calculate the sales tax
varSalesTax = varSalesTotal * 0.04

'Prepare the return envelope
strTmp = &quot;&quot;
strTmp = strTmp + &quot;<SOAP:Envelope xmlns:SOAP=&quot;&quot;urn:schemas-xmlsoap-org:soap.v1&quot;&quot;>&quot; & _
&quot;<SOAP:Header></SOAP:Header>&quot; & _
&quot;<SOAP:Body>&quot; & _
&quot;<m:GetSalesTaxResponse xmlns:m=&quot;&quot;urn:myserver/soap:TaxCalc&quot;&quot;>&quot; & _
&quot;<SalesTax>&quot; & varSalesTax & &quot;</SalesTax>&quot; & _
&quot;</m:GetSalesTaxResponse>&quot; & _
&quot;</SOAP:Body>&quot; & _
&quot;</SOAP:Envelope>&quot;

'Write the return envelope
Response.Write strTmp

%>

If someone could give me a hint I would appreciate it. It does not appear to be a firewall. The response error is as follows:

Code:
Reference to undeclared namespace prefix: 'SOAP'.

Thanks for your help,

Ben
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top