none
Sending unencoded XML to SOAP web service RRS feed

  • Question

  • Hi,

    Apologies if this has gone in the wrong section.  I've tried searching extensively and found little.

    I'm trying to write a client that communicates to a third party SOAP service which I have no control over using WCF.  The service in question has the unfortunate design whereby all the methods it exposes through its WSDL take a single string as a parameter, and return a single string.  The input string parameter requires XML wrapped in a CDATA tag.  I realise that this is horrendous design, however I'm stuck with it.

    I've successfully generated proxy classes for calling the web services in VS 2012 by adding a service reference to the project.  However, if I serialize some XML and pass it in as a string parameter as expected by the service, WCF (as you would expect) HTML encodes the XML (e.g. replaces < characters with &lt; etc) - the web service at the other end rejects this.  I need to know if it's possible to tell the proxy classes to treat string inputs literally without performing the encoding, i.e. accept raw XML and send it as is.

    I suspect I need to use the IClientMessageFormatter in some way, but I'm not sure how.

    Please help.  Let me know if anything is unclear.

    • Moved by Kristin Xie Tuesday, January 6, 2015 2:18 AM move to approprite forum
    Monday, January 5, 2015 2:11 AM

Answers

All replies

  • Hi amn681012,

    Visual C# forum is discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    Your case related to WCF Web services. I am afraid this is not an appropriate forum. I will move your thread to WCF forum for better support.

    Have a good day!

    kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 6, 2015 2:18 AM
  • Hi,

    The ampersand character (&) and the left angle bracket (<) must not appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings " &amp; " and " &lt; " respectively. The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility, be escaped using either " &gt; " or a character reference when it appears in the string " ]]> " in content, when that string is not marking the end of a CDATA section.

    If you are referring to encoding/decoding of XML names, there is XmlConvert.EncodeName and DecodeName.

    However, in this situation, you communicate to a third party SOAP service, and it takes a single string as a parameter. Since you have no control over using WCF, so it’s recommended that you could just pass the exact needed parameter to the service.

    For more information, you could refer to:

    http://stackoverflow.com/questions/6898259/whats-all-about-escaping-characters-in-xml

    http://stackoverflow.com/questions/2597615/passing-xml-as-a-parameter-to-a-web-service

    http://stackoverflow.com/questions/2597056/is-there-an-xmlencode-xmldecode-for-net/2597262#2597262

    Regards

    Tuesday, January 6, 2015 7:12 AM
    Moderator