I have webservices at the following link:
http://abc.com/asmx
I have made the request to webservice getcustomers using following code:
<%
DIM PostData, strStatus, strRetVal, postUrl
PostData = _
"<?xml version=""1.0"" encoding=""utf-8""?>" &_
"<soap:Envelope xmlns:env=""http://www.w3.org/2001/XMLSchema-instance"" &_
"xmlns:xsd='http://www.w3.org/2001/XMLSchema'" &_
"xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" &_
"<soap:Body>" &_
" <getCustomer xmlns=""http://3dcart.com/"">" &_
"<storeUrl>www.abc.stores.com/</storeUrl>" &_
"<userKey>sdfsf</userKey>" &_
"<batchSize>1</batchSize>" &_
"<startNum>1</startNum>" &_
"<customersFilter>firstname=John</customersFilter>"&_
"<callBackURL></callBackURL>"&_
"</getCustomer>"&_
"</soap:Body>" &_
"</soap:Envelope>"
response.write("req=" & Server.HTMLEncode(PostData) & "<br/>len=" & len(PostData))
postUrl = "http://abc.com/cart.asmx?op=getCustomer"
Set xmlHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlHTTP.open "POST", postUrl, false
xmlHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
'xmlHTTP.setRequestHeader "SOAPAction", "http://AvailReceive/AvailRq"
xmlHTTP.send PostData
strStatus = xmlHTTP.Status
strRetval = xmlHTTP.responseText
set xmlHTTP = nothing
response.write("<br/>")
response.write("status=" & strStatus & "<br/>resp=" & strRetval)
%>
But i am getting error:
resp=soap:ReceiverServer was unable to process request. —> ‘http’ is an unexpected token. Expecting white space. Line 1, position 163.
can you please advise why am i getting this error what is the solution to it.
yes:
the reason you are getting the 500 error (“expecting white space”) is that your message is malformed. You have several xmlns declarations in the xml message, and because of a bug in your vbscript, there is no space between them. The result is invalid XML, and the server is returning the error because of it.
Also:
envandxsdin your message. They are never used.soapprefix either. You can just set the default XML namespace.Using those suggested changes, Here is some code that works properly:
But …this code uncovers a runtime error in the .ASMX script.
If I modify the outgoing message to specify the hostname as
abc.cominstead ofwww.abc.com, then I get a reasonable-looking response.