INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Sending SOAP Messages w/ XML in the Body

Sending SOAP Messages w/ XML in the Body

(OP)
Hi,

I'm using MSXML2.ServerXMLHTTP50 in vb6 to send soap messages to a very simple method on a web service. I've copied the sample soap request below:

CODE

POST /bla/bla.asmx HTTP/1.1
Host: testpc
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.myuri.com/bla/bla/Test"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="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>
    <Test xmlns="http://www.myuri.com/bla/bla">
      <sMsg>string</sMsg>
    </Test>
  </soap:Body>
</soap:Envelope>

The problem is that i'm trying to send xml in the <sMsg> tag which won't work unless i surround it in <![CDATA[like this]]>. Although that's not great the real problem comes when the service returns another xml document to me in its return value (see soap response below):

CODE

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

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="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>
    <TestResponse xmlns="http://www.myuri.com/bla/bla">
      <TestResult>string</TestResult>
    </TestResponse>
  </soap:Body>
</soap:Envelope>

All the special xml characters have been translated to their entity representations i.e. < to &lt;, > to &gt; etc which isn't great.

Has anyone got any ideas how i get around this.

I'd really appreciate any help possible.

Thanks in advance!!

p.s. I've also tested the service using a c# windows app & had a packet sniffer running when the call to the method was made & I can see exactly the same thing is happening there too, but i'm guessing the framework is doing the translation from xml to text & back again for me.

RE: Sending SOAP Messages w/ XML in the Body

(OP)
I've found the answer. I need to use XmlDocument's as params in the web service, rather than string's.

RE: Sending SOAP Messages w/ XML in the Body

Milby,

I'm tring to send (via SOAP) a document via xml and vb6 and I'm having problems.  Do you have a sample code you can send for me to take a look at?

Thanks, Mike
mike@mikekelleyconsulting.com

RE: Sending SOAP Messages w/ XML in the Body

(OP)
Hi Mike,

In vb6 you'd end up with something that looks similar to this (i've omitted variable declarations & error handling):

CODE

Set server = New MSXML2.ServerXMLHTTP50

server.setTimeouts lTimeout, lTimeout, lTimeout, lTimeout

server.Open "POST", sUrl, False

' what the message will contain
server.setRequestHeader "Content-Type", "text/xml; charset=utf-8"

' what we want to invoke
server.setRequestHeader "SOAPAction", "http://www.action-uri.com/bla/bla/bla"

server.send sXml

sResponse = server.responseText

Set server = Nothing

'sXml' contains the entire soap message. that will obviously depend on what the method on your web service is expecting. it might look something like this:

CODE

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="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>
    <MethodNameGoesHere xmlns="http://www.service-uri.com/bla/bla/bla">
      <ParamNameGoesHere>your xml document goes here</ParamNameGoesHere>
    </MethodNameGoesHere>
  </soap:Body>
</soap:Envelope>

You should be able to get an example soap message by typing the url of the web service into a browser & then clicking on the hyperlink for the method you're interested in calling.

I hope this helps.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close