Link to home
Start Free TrialLog in
Avatar of pyromyst
pyromyst

asked on

Sending/Receiving XML documents via Web Pages

Hi,

I have need of a system where I can request data from a web site in one country using my web site in another country.
This to and fro is to be in the form of XML documents using SSL (HTTPS).

When I need information from the web site I send it a request in the form of an XML document. The response I receice will be an XML document.
This initial request is to be performed using an ASP web page running off IIS.

I need to find a way of sending an XML request to this other site and then receiving an XML response.

How do I do this?
ASKER CERTIFIED SOLUTION
Avatar of mattyk
mattyk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
pyromyst,

Something originally put together for Sun's JDC:

http://developer.java.sun.com/developer/qow/archive/84/index.html

Regards,
WMB
Avatar of macshiva
macshiva


Try this!

asp1 sending datapacket:

Set objhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")

objhttp.setRequestHeader "Content-Type", "text/xml"

then use soap packet to send the xml content:

objhttp.Open "post", "http://******/***.asp", False

   strMethodPkg = "<SOAP:Envelope xmlns:SOAP=""urn:schemas-xmlsoap-org:soap.v1"">"
   strMethodPkg = strMethodPkg & "<SOAP:Header></SOAP:Header>"
   strMethodPkg = strMethodPkg & "<SOAP:Body><m:XMLPass xmlns:m=""urn:soapserver/soap:XMLModule"">"
   strMethodPkg = strMethodPkg & "<XMLString>" & <<this is xml>> & "</XMLString>"
   strMethodPkg = strMethodPkg & "</m:PassXML></SOAP:Body></SOAP:Envelope>"

objhttp.send strMethodPkg

''send pack to receiver end
''after this

strresult = objhttp.responseText
 
obx.loadXML strresult


Receiving End asp2:

Set objXMLDOM = Server.CreateObject("Microsoft.XMLDOM")
objXMLDOM.Load Request

''You validate according to your need
varXMLBack = objXMLDOM.SelectSingleNode("SOAP:Envelope/SOAP:Body/m:XMLPass/XMLString").Text

strResultXML = "<SOAP:Envelope xmlns:SOAP=""urn:schemas-xmlsoap-org:soap.v1""><SOAP:Header></SOAP:Header>"

strResultXML = strResultXML & "<SOAP:Body><m:XMLStrResponse xmlns:m=""urn:soapserver/soap:XMLModule"">"

strResultXML = strResultXML & "<XMLResult>" & varXMLBack & "</XMLResult></m:XMLStrResponse>"
strResultXML = strResultXML & "</SOAP:Body></SOAP:Envelope>"

Response.Write strResultXML

Best Regards,
Shiva
Avatar of pyromyst

ASKER

The ServerXMLHTTP object seems to be what I need, however all data that I send has its spaces stripped out.
I haven't been able to figure out why this happens but it does mean that all attempts at sending an XML string containing attributes fail.

If I were to send this XML:

<myXML>
  <Head Version="1.0">
    <Title>XML Stuff</Title>
  </Head>
</myXML>

I would get the XML below on the receiver page:

<myXML>
  <HeadVersion="1.0">
    <Title>XMLStuff</Title>
  </Head>
</myXML>

It seems that the send method of ServerXMLHTTP takes out spaces.

How can I prevent this?
The ServerXMLHTTP object seems to be what I need, however all data that I send has its spaces stripped out.
I haven't been able to figure out why this happens but it does mean that all attempts at sending an XML string containing attributes fail.

If I were to send this XML:

<myXML>
  <Head Version="1.0">
    <Title>XML Stuff</Title>
  </Head>
</myXML>

I would get the XML below on the receiver page:

<myXML>
  <HeadVersion="1.0">
    <Title>XMLStuff</Title>
  </Head>
</myXML>

It seems that the send method of ServerXMLHTTP takes out spaces.

How can I prevent this?
Hi again,

It has been a while since I posted my last comment but I have still not received an answer.

Using ServerXMLHTTP seems to be the solution, BUT only if it will send spaces. See my previous comment for details.
I have finally found a solution for keeping spaces when sending the data. The data is sent URLEncoded so I simply replaced all spaces with '%20' before sending.

It works fine now. :)

(NOTE: This would have been an excellent had I been told how to keep spaces, but not getting an answer wasted much of my valuable time.)