简体   繁体   中英

ASP Classic, SOAP / XML Request and response

Fairly new to this so please bear with me.

i have been given this as a request

POST /weblordinterface/interface.asmx HTTP/1.1
Host: weblord-test.toshiba-tro.de
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <_getCaseById xmlns="http://weblord.toshiba-tro.de/">
      <sIdCase>string</sIdCase>
      <sUser>string</sUser>
      <sPassword>string</sPassword>
    </_getCaseById>
  </soap12:Body>
</soap12:Envelope> 

from the servicve provider and this as a response

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <_getCaseByIdResponse xmlns="http://weblord.toshiba-tro.de/">
      <_getCaseByIdResult>xml</_getCaseByIdResult>
    </_getCaseByIdResponse>
  </soap12:Body>
</soap12:Envelope>

i have written an ASP page that has the IDcase / user / password forwarded to me and i know this part works as i can display all 3 onscreen.

my code is :-

<%

dim sUser 
dim sPassword
dim sIdCase

sIdCase=Request.QueryString("sIdCase")
sPassword=Request.QueryString("sPassword")
sUser=Request.QueryString("sUser")

Dim objXMLHTTP 
set objXMLHTTP = server.Createobject("MSXML2.ServerXMLHTTP.3.0") 

Dim strRequest, strResult, 


strRequest ="<?xml version='1.0' encoding='utf-8'?><soap12:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'  xmlns:xsd='http://www.w3.org/2001/XMLSchema'  xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'>" _
& "    <soap12:Body><_getCaseById xmlns='http://weblord.toshiba-tro.de/'><sIdCase>" & sIdCase & "</sIdCase>" _
& "            <sUser>" & sUser & "</sUser> <sPassword>" & sPassword & "</sPassword></_getCaseById></soap12:Body></soap12:Envelope>"
objXMLHTTP.open "POST", "http://weblord.toshiba-tro.de/weblordinterface/interface.asmx" , true
objXMLHTTP.setRequestHeader "User-Agent","HTTP/1.1"
objXMLHTTP.setRequestHeader "Host","weblord-test.toshiba-tro.de"
objXMLHTTP.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8"
objXMLHTTP.setRequestHeader "Content-Length", Len(strRequest)
'objXMLHTTP.setRequestHeader "SOAPAction", "http://weblord.toshiba-tro.de/"

objXMLHTTP.send(strRequest)


If objXMLHTTP.status = 200 Then
    TextResponse = objXMLHTTP.responseText
    XMLResponse = objXMLHTTP.responseXML
    StreamResponse = objXMLHTTP.responseStream
Else
    response.write("we have an error")
End If

Set objXMLHTTP = Nothing


%>

Can someone please enlighten me as to how i can get the response and display it, i seem to get an error at the

If objXMLHTTP.status = 200 Then

line of

msxml3.dll error '8000000a'

The data necessary to complete this operation is not yet available.

Can one of you experts please help

You are specifying an asynchronous request when you open the connection. So the data is not yet available in the subsequent code. Change this to a synchronous request instead.

ie. change from this...

objXMLHTTP.open "POST", "http://weblord.toshiba-tro.de/weblordinterface/interface.asmx" , true

...to this...

objXMLHTTP.open "POST", "http://weblord.toshiba-tro.de/weblordinterface/interface.asmx" , false

Figured it out folks

Host: weblord-test.toshiba-tro.de

is what was given, i was posting to

objXMLHTTP.open "POST", " http://weblord.toshiba-tro.de/weblordinterface/interface.asmx "

Once i added -test in it now works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM