DJOKO DJOKO - 22 days ago 6
C# Question

How store URL with '&' character in SOAP message

I have created a Windows service which uploads media files (.ts, .mpg, ...) into a CDN FTP repository then the CDN invokes a web service to get a download link for each file.

The download link is like this:

http://CompanyName-­‐yy.XXX.net/XXX/folder.asp?param1=636&param2=123


Then I store all download links into a SOAP message and I invoke another web service.

My question: how do I save a url with the character
&
without encoding it? If I have to encode it, should the other party which receives my request decode it again?

Answer

You're sending an XML request so you have to encode it according to XML standards. This includes replacing & in values with the & entity, unless you're using CDATA content.

Decoding it is the responsibility of the client, and unless he is using a completely barebones or selfwritten XML parser that should already be handled by the parser they use.

That said, I'm wondering how you are invoking the SOAP request to begin with? Usually when you create a web service adapter using the WSDL file you just fill out the corresponding class properties and send the request, without having to think about encoding at all.