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 at why I am getting the a "Object Variable or with block not set." at the following line of code I would appreciate it:
It does not appear to be a firewall. The response string 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:
<%
Set objReq = Server.CreateObject("MSXML2.DOMDocument")
'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 = _
"<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 at why I am getting the a "Object Variable or with block not set." at the following line of code I would appreciate it:
Code:
dblTax = objReturn.selectSingleNode(strQuery).Text
It does not appear to be a firewall. The response string is as follows:
Code:
<font face="Arial" size=2>
<p>Microsoft VBScript runtime </font> <font face="Arial" size=2>error '800a01a8'</font>
<p>
<font face="Arial" size=2>Object required: 'objReq.SelectSingleNode(...)'</font>
<p>
<font face="Arial" size=2>/bnye/UpdateApplication.asp</font><font face="Arial" size=2>, line 10</font>
Thanks for your help,
Ben