Link to home
Start Free TrialLog in
Avatar of inges
inges

asked on

ASAP , problem with xmlhttp

I have a big problem with xmlhttp.
When I send an xml as string using parameters and I want to get an xml back.  All the spaces are removed from the xml.  How come?  This is the code I use.

Set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
objHttp.Open "POST", "this is the correct url, False
objhttp.setRequestHeader "Content-Type","application/x-ww-form-urlencoded"
objHttp.Send <this is the xml>
response.write objHttp.responseText
Set objHttp = Nothing
Avatar of hongjun
hongjun
Flag of Singapore image

Can you post the actual code instead of all those <..>. Also post what you see when you do the response.write

hongjun
How about doing this?
Response.Write xmlhttp.responseXML.xml

hongjun
Avatar of inges
inges

ASKER

I've tried the xmlhttp.responsexml.xml.
I still get an xml-string back with the spaces removed.
I would post the complete xml, but is it rather big but you understand the problem so ... .
Avatar of inges

ASKER

I've tried the xmlhttp.responsexml.xml.
I still get an xml-string back with the spaces removed.
I would post the complete xml, but is it rather big but you understand the problem so ... .
Are those spaces replaced by any characters?

hongjun
Avatar of inges

ASKER

No not replaced, just gone
ASKER CERTIFIED SOLUTION
Avatar of EDDYKT
EDDYKT
Flag of Canada image

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
I suppose you post the xml to an asp. In this case you must add:    

Response.contentType = "text/xml"

before sending anything back to the browser.
Avatar of inges

ASKER

So how do you decode you're xml-string if you have used server.htmlencode
-------------------------------------------------------
I've tried it with the reponse.contenttype
Try this
response.write Server.HTMLEncode(objHttp.responseText)

hongjun
I am not sure it is supported by the browser side since it is wise to use the old version of XML: Microsoft.XMLHTTP you may not have to.

On the server side:
xmldoc.preserveWhiteSpace = true

use Msxml2.DOMDocument if you cannot use it.
Avatar of inges

ASKER

It happens in the send.
I send an xml string to the server and when ik gets there the spaces are gone.
Inges,

  Try this way!,

Use
Dim obx As New MSXML2.DOMDocument
Dim objhttp As MSXML2.ServerXMLHTTP

Set objhttp = New MSXML2.ServerXMLHTTP

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

then use soap packet to send the xml content:

    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:

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

***********************************************************
I am actually using posting xml to a server and getting xml out as well.  I have not found a way to get the spaces back.  I thought that through VB's XML DOM component, you can set the preserveWhiteSpaces to true and it should work.  I have tried to set this to true and false and it has not worked.  If you find an answer, let me know.  I will do the same for you.
the first sending part is from VB and the receiving end
is in asp..
Avatar of inges

ASKER

Thanks, It was not server.HTMLEncode but server.URLEncode.