k0pernikus
k0pernikus

Reputation: 66797

How to escape special chars in an xml soap body for a soap request?

I am trying to consume a soap server. Values needs to be sent which may contain certain special chars, namely ', &, $ :, and *, e.g.:

foo'bar&$bazz:*

I now that the value is correct, as I can consume the soap api indirectly through an external webfrontend that internally communicates with the soap server. I do not know what kind of transformation it applies to the payload nor do I have access to check.

I wonder: Is there a common way to escape / encode special chars for soap requests?

I tried using cdata:

<![CDATA[foo'bar&$bazz:*]]>

I tried using escape sequences:

& (ampersand): &#38;
' (apostrophe or single quote): &#39;

yet all to no avail.

I am trying to contact the provider of the soap service, yet in the meantime I wonder if there is a common escaping strategy that I can employ that should be default for soap servers to understand.

Upvotes: 1

Views: 2614

Answers (1)

k0pernikus
k0pernikus

Reputation: 66797

The escape strategy that worked for me was to not escape the ' but only the &like this:

foo'bar&amp;$bazz:*

Upvotes: 1

Related Questions