DJOKO DJOKO - 1 year ago 78
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:


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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download