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:
The ASP page is as follows:
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:
Thanks for your help,
Ben
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 = _
"<soap:envelope xmlns:soap=""urn:schemas-xmlsoap-org:soap.v1"">" & _
"<soap:header></soap:header>" & _
"<soap:body>" & _
"<m:getsalestax xmlns:m=""urn:myserver/soap:TaxCalculator"">" & _
"<salestotal>100</salestotal>" & _
"</m:getsalestax>" & _
"</soap:body>" & _
"</soap:envelope>"
'Set up to post to our local server
objhttp.open "post", "[URL unfurl="true"]http://www.assetmarketingsystems.net/bnye/UpdateApplication.asp",[/URL] False
'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:TaxCalculator#GetSalesTax"
'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 = _
"SOAP:Envelope/SOAP:Body/m:GetSalesTaxResponse/SalesTax"
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("Microsoft.XMLDOM")
Set objReq = Server.CreateObject("MSXML2.DOMDocument.4.0")
'Load the request into XML DOM
objReq.Load Request
'Query the DOM for the input parameter
strQuery = "SOAP:Envelope/SOAP:Body/m:GetSalesTax/SalesTotal"
varSalesTotal = objReq.SelectSingleNode(strQuery).Text
'Calculate the sales tax
varSalesTax = varSalesTotal * 0.04
'Prepare the return envelope
strTmp = ""
strTmp = strTmp + "<SOAP:Envelope xmlns:SOAP=""urn:schemas-xmlsoap-org:soap.v1"">" & _
"<SOAP:Header></SOAP:Header>" & _
"<SOAP:Body>" & _
"<m:GetSalesTaxResponse xmlns:m=""urn:myserver/soap:TaxCalc"">" & _
"<SalesTax>" & varSalesTax & "</SalesTax>" & _
"</m:GetSalesTaxResponse>" & _
"</SOAP:Body>" & _
"</SOAP:Envelope>"
'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