Msxml2.ServerXMLHTTP.4.0 + &
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > IIS server support > IIS ASP > Msxml2.ServerXMLHTTP.4.0 + &




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Msxml2.ServerXMLHTTP.4.0 + &  
ashton


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-30-04 11:01 PM

Hello,

I have a process that has been sending an xml file to a different web server
 using Msxml2.ServerXMLHTTP.4.0 and I just recently came into a problem.

This is how it works:
password=Request.Form("password")
password=Request.Form("password")
xmlData = Request.Form("xmlData")
Set xmlConnection = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
xmlConnection.Open "POST", sendServer, False
xmlConnection.setRequestHeader "Content-Type", "application/x-www-form-urlen
coded"
xmlConnection.Send "username="+username+"&username="+username+"&xml="+xmlDat
a

This works just fine until the xml has an & sign in it, from what I gather w
hen I type this line:
xmlConnection.Send "username="+username+"&username="+username+"&xml="+xmlDat
a

The & character in the xml breaks the xml variable apart. If my xml looked l
ike this <basic>george & wallace</basic>
The url string would look like this:

server?username=user&password=pass&xml=<basic>george & wallace</basic>

so the server would receive the following variables:
username=user
password=password
xml = <basic>george
wallace=</basic>

Does this make sense? Is there a way I can get around this?





[ Post a follow-up to this message ]



    Re: Msxml2.ServerXMLHTTP.4.0 + &amp;  
Chris Barber


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-30-04 11:01 PM

You have to encode the ampersand as & or use the unicode number (0026 - 
not sure about the
actual format for this) or the numeric format & (which I prefer).

The obvious problem is handling how this is output to the resultant XML / HT
ML / text when using an
XSL transform - a big topic.

Note that when DOM methods are used to put the value into an XML document th
en the XML parser
automagically puts the encoded version on for you - getting it out again is 
another matter entirely.

Chris.

"ashton" <ashton@discussions.microsoft.com> wrote in message
news:8A350E6A-F75C-4594-A54A-E613D8D3FC9A@microsoft.com...
Hello,

I have a process that has been sending an xml file to a different web server
 using
Msxml2.ServerXMLHTTP.4.0 and I just recently came into a problem.

This is how it works:
password=Request.Form("password")
password=Request.Form("password")
xmlData = Request.Form("xmlData")
Set xmlConnection = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
xmlConnection.Open "POST", sendServer, False
xmlConnection.setRequestHeader "Content-Type", "application/x-www-form-urlen
coded"
xmlConnection.Send "username="+username+"&username="+username+"&xml="+xmlDat
a

This works just fine until the xml has an & sign in it, from what I gather w
hen I type this line:
xmlConnection.Send "username="+username+"&username="+username+"&xml="+xmlDat
a

The & character in the xml breaks the xml variable apart. If my xml looked l
ike this <basic>george &
wallace</basic>
The url string would look like this:

server?username=user&password=pass&xml=<basic>george & wallace</basic>

so the server would receive the following variables:
username=user
password=password
xml = <basic>george
wallace=</basic>

Does this make sense? Is there a way I can get around this?


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.712 / Virus Database: 468 - Release Date: 27/06/2004







[ Post a follow-up to this message ]



    Re: Msxml2.ServerXMLHTTP.4.0 + &amp;  
ashton


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-30-04 11:01 PM

Hi Chris, thanks for the reply.

Let me try to rephrase my question.

I am trying to send 3 variables using Msxml2.ServerXMLHTTP.4.0

The first variable is the username, the second the password, and the last va
riable is a block of xml.

This process has been working fine, until I came across the & symbol.

I have many different systems running that are translating xml, so whenever 
I have this problem it is just a matter of changing the character from & to 
& (I'm not sure how this formatting will display in the newsgroups so I 
format the & sign to & a m
p ;)

This usually does the trick. In this case it does not seem to have any effec
t and I still get an error from the web site I post the xml to. The error al
ways says the same thing; there is a problem with line X (where X is the lin
e with the & symbol).

From what I have gathered the problem isn't how I am sending the & chara
cter, because I know I am sending it properly formatted. But from the way Ms
xml2 posts my information.

This line:

xmlConnection.Send "user="+username+"&pass="+password+"&xml="+xmlData

In this line I am just connecting strings together. Could this be the proble
m?

Let's say my "username" variable was joe&bard

That line above would translate to:

xmlConnection.Send "user=joe&bard"&pass="+password+"&xml="+xmlData

And if my password value was pass2, and the xmlData was <xml></xml>

It would be fully translated as:

xmlConnection.Send "user=joe&bard&pass=pass2&xml=<xml></xml>"

So when the web server on the other side tries to get the value of "user" th
ey would only get "bard" as a response. Correct?

Even if the & sign was changed to & It would look like this:

xmlConnection.Send "user=joe&bard&pass=pass2&xml=<xml></xml>"
or (depending on newsgroup formatting)
xmlConnection.Send "user=joe&amp;bard&pass=pass2&xml=<xml></xml>"

And (in either example) when the person requested the value of "user" they w
ould still only get "joe". That's because the & sign is forcing that variabl
e to end.

The same with the xml, the & sign, no matter if it is formatted or not (&, &
amp;, &) is forcing that variable to end.

This is what I am thinking is happening to my xml when I send it. What I nee
d to know is if there is a way to rewrite my xmlConnection.Send line so it d
oes not have all of the variables concatenated on a single string. Or a way 
to eliminate this ampersand
problem?






[ Post a follow-up to this message ]



    Re: Msxml2.ServerXMLHTTP.4.0 + &amp;  
Mark Schupp


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-30-04 11:01 PM

xmlConnection.Send "user="+username+"&pass="+password+"&xml="+
server.URLEncode(xmlData)


--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com


"ashton" <ashton@discussions.microsoft.com> wrote in message
news:3440D147-9C1F-4E97-A173-F40AC252623B@microsoft.com...
> Hi Chris, thanks for the reply.
>
> Let me try to rephrase my question.
>
> I am trying to send 3 variables using Msxml2.ServerXMLHTTP.4.0
>
> The first variable is the username, the second the password, and the last
variable is a block of xml.
>
> This process has been working fine, until I came across the & symbol.
>
> I have many different systems running that are translating xml, so
whenever I have this problem it is just a matter of changing the character
from & to & (I'm not sure how this formatting will display in the
newsgroups so I format the & sign to & a m p ;)
>
> This usually does the trick. In this case it does not seem to have any
effect and I still get an error from the web site I post the xml to. The
error always says the same thing; there is a problem with line X (where X is
the line with the & symbol).
>
> From what I have gathered the problem isn't how I am sending the &
character, because I know I am sending it properly formatted. But from the
way Msxml2 posts my information.
>
> This line:
>
> xmlConnection.Send "user="+username+"&pass="+password+"&xml="+xmlData
>
> In this line I am just connecting strings together. Could this be the
problem?
>
> Let's say my "username" variable was joe&bard
>
> That line above would translate to:
>
> xmlConnection.Send "user=joe&bard"&pass="+password+"&xml="+xmlData
>
> And if my password value was pass2, and the xmlData was <xml></xml>
>
> It would be fully translated as:
>
> xmlConnection.Send "user=joe&bard&pass=pass2&xml=<xml></xml>"
>
> So when the web server on the other side tries to get the value of "user"
they would only get "bard" as a response. Correct?
>
> Even if the & sign was changed to & It would look like this:
>
> xmlConnection.Send "user=joe&bard&pass=pass2&xml=<xml></xml>"
> or (depending on newsgroup formatting)
> xmlConnection.Send "user=joe&amp;bard&pass=pass2&xml=<xml></xml>"
>
> And (in either example) when the person requested the value of "user" they
would still only get "joe". That's because the & sign is forcing that
variable to end.
>
> The same with the xml, the & sign, no matter if it is formatted or not (&,
&, &) is forcing that variable to end.
>
> This is what I am thinking is happening to my xml when I send it. What I
need to know is if there is a way to rewrite my xmlConnection.Send line so
it does not have all of the variables concatenated on a single string. Or a
way to eliminate this ampersand problem?
>







[ Post a follow-up to this message ]



    Re: Msxml2.ServerXMLHTTP.4.0 + &amp;  
ashton


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-30-04 11:01 PM

Thanks!





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:24 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register