help! why doesnt this work...or is there a better way?

W

wptpro

I need to send a soap message, is this the correct way of doing it? I
get an error back..."parsing error: org.xml.sax.SAXParseException:
Premature end of file."


Dim strRequest As String
Dim oXML As Object
Dim strResult As String


strRequest = "<?xml version='1.0' encoding='UTF-8' ?>" & vbCrLf

strRequest += "<SOAP-ENV:Envelope
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'xmlns:xsi='http://www.w3.or...

xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" & vbCrLf
strRequest += "<SOAP-ENV:Header>" & vbCrLf
strRequest += "<Authentication>" & vbCrLf
strRequest += " <application_id>accountid</application_id>" &
vbCrLf
strRequest += " <password>thepassword</password>" & vbCrLf
strRequest += "</Authentication>" & vbCrLf
strRequest += "</SOAP-ENV:Header>" & vbCrLf
strRequest += "<SOAP-ENV:Body>" & vbCrLf
strRequest += " <ns1:getHandsetByPTN
SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'xmlns:SOAP-ENV='http://sche...

xmlns:ns1='urn:HandsetService'>" & vbCrLf
strRequest += " <applRef xsi:nil='true'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:type='xsd:string' />" & vbCrLf
strRequest += " <ptn xsi:type='xsd:string'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>8586883672</ptn>"

& vbCrLf
strRequest += "</ns1:getHandsetByPTN>" & vbCrLf
strRequest += "</SOAP-ENV:Body>" & vbCrLf
strRequest += "</SOAP-ENV:Envelope>"


' Create an xmlhttp object:
oXML = CreateObject("MSXML2.ServerXMLHTTP")
oXML.open("POST", "https://the url goes here", False)
oXML.setRequestHeader("Content-Type", "text/xml")
oXML.SetRequestHeader("Content-length", strRequest.Length)
oXML.SetRequestHeader("Connection", "Keep-Alive")
oXML.Send(strRequest)
 
J

Josh Twist

You'd really need to look at what the end result of strRequest is...
Debug your code and/or write it to a file. Then make sure you're
creating valid XML by viewing it in an XML editor (or Internet
Explorer).

If all that is OK - then we can have a look at your soap for you :)

Josh
http://www.thejoyofcode.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top