all groups > inetserver asp db > february 2005 >
You're in the

inetserver asp db

group:

Object Required Error



Object Required Error westernnord NO[at]SPAM webtv.net
2/27/2005 7:48:57 PM
inetserver asp db: I am getting the following error:
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'objReq.SelectSingleNode(...)'
/soap.asp, line 10

I am using Windows XP with IIS installed. There is an ASP page sending a
SOAP request to the following page. Here is the code receiving the error:

<%
Dim strQuery
Dim varSalesTotal
Set objReq = Server.CreateObject("Microsoft.XMLDOM")

'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
%>

I would have posted this in microsoft.public.xml.soap, but no one seems to
respond to the questions. I'm hoping that someone in this active group can
help.

Regards, Richard

Re: Object Required Error westernnord NO[at]SPAM webtv.net
2/27/2005 8:00:15 PM
Just in case you need the SOAP request ASP page, here it is:

<%
Dim Reg
Dim xml
Dim RetVal
Reg = "<soap:envelope xmlns:soap=""urn:schemas-xmlsoap-org:soap.v1"">" &
vbCrLf
Reg = Reg & "<soap:header></soap:header>" & vbCrLf
Reg = Reg & "<soap:body>" & vbCrLf
Reg = Reg & "<m:getsalestax xmlns:m=""urn:myserver/soap:TaxCalculator"">" &
vbCrLf
Reg = Reg & "<salestotal>100</salestotal>" & vbCrLf
Reg = Reg & "</m:getsalestax>" & vbCrLf
Reg = Reg & "</soap:body>" & vbCrLf
Reg = Reg & "</soap:envelope>"
Response.Write(Reg)
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.open "post", "http://localhost/soap.asp", False
xml.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
xml.setRequestHeader "SOAPMethodName",
"urn:myserver/soap:TaxCalculator#GetSalesTax"
xml.send Reg
RetVal = xml.responseText
Response.Write(RetVal)
Response.End
Set xml = nothing
%>


[quoted text, click to view]

Re: Object Required Error Bob Barrows [MVP]
2/28/2005 6:49:31 AM
[quoted text, click to view]

The problem is easily stated: selectSinglenode is not finding the node
specified by strQuery. To avoid this error you need to do this:

Dim oNode
Set oNode=Nothing
Set oNode=objReq.SelectSingleNode(strQuery)
if not oNode is Nothing Then
varSalesTotal = oNode.Text
else
'handle the error - save the xml to a file so you can look at it
end if

As to fixing strQuery, we cannot do that without seeing the xml in Request.

<hint>
Remember: xpath is case sensitive. "SalesTotal" is not the same as
"salestotal"
</hint>

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Re: Object Required Error westernnord NO[at]SPAM webtv.net
2/28/2005 7:04:09 PM
Outstanding Bob. There were a lot of case sensitive problems with the xml on
both pages.
I don't know what I would have done without your help.

Best regards, Richard

[quoted text, click to view]

AddThis Social Bookmark Button