Solved

ASAP , problem with xmlhttp

Posted on 2001-08-10
16
259 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:inges
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
  • +3
16 Comments
 
LVL 33

Expert Comment

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

hongjun
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6371538
How about doing this?
Response.Write xmlhttp.responseXML.xml

hongjun
0
 

Author Comment

by:inges
ID: 6371552
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 ... .
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Comment

by:inges
ID: 6371553
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 ... .
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6371609
Are those spaces replaced by any characters?

hongjun
0
 

Author Comment

by:inges
ID: 6371710
No not replaced, just gone
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 300 total points
ID: 6372211
If you remember correctly, you have to encode your xml string, ie. using Server.HTMLEncode
0
 
LVL 2

Expert Comment

by:ZhongYu
ID: 6372505
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.
0
 

Author Comment

by:inges
ID: 6372530
So how do you decode you're xml-string if you have used server.htmlencode
-------------------------------------------------------
I've tried it with the reponse.contenttype
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6372543
Try this
response.write Server.HTMLEncode(objHttp.responseText)

hongjun
0
 
LVL 2

Expert Comment

by:ZhongYu
ID: 6372621
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.
0
 

Author Comment

by:inges
ID: 6372642
It happens in the send.
I send an xml string to the server and when ik gets there the spaces are gone.
0
 

Expert Comment

by:macshiva
ID: 6373827
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

***********************************************************
0
 

Expert Comment

by:midavis
ID: 6374074
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.
0
 

Expert Comment

by:macshiva
ID: 6381583
the first sending part is from VB and the receiving end
is in asp..
0
 

Author Comment

by:inges
ID: 6490079
Thanks, It was not server.HTMLEncode but server.URLEncode.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Call a function within the ASP code 4 34
Obtaining data on ASP 8 43
ASP Classic - Read XML File inner content 10 74
JSON Error in ASP Page 3 39
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question