none
CustomTextMessageEncoder Configuration Unrecognized RRS feed

  • Question

  • I'm trying to run the CustomTextMessageEncoder sample to handle cases where a web service call return extended ascii characters. My code is C# in an Excel spreadsheet. My understanding is I need to create an XMLReader with a stream that has UTF8Encoding set to not throw an exception on invalid characters. Anyway, my configuration has an issue. It keeps throwing "Unrecognized element 'customTextMessageEncoding'" on the <binding...> tag when I now make the web service call. Following is my config:

          <client>
            <endpoint address="http://TheWebAddressAndServlet"
                binding="basicHttpBinding" bindingConfiguration="MyWebServiceBinding"
                contract="MyServiceReference" name="MyPort" />
          </client>
          <!-- -->
          <bindings>
            <basicHttpBinding>
              <binding name="MyWebServiceBinding">
                <customTextMessageEncoding encoding="utf-8" mediaType="text/xml" messageVersion="None" />
                <httpTransport/>
              </binding>
            </basicHttpBinding>
          </bindings>
          <extensions>
            <bindingElementExtensions>
              <add name="customTextMessageEncoding" type="MyNamespace.CustomTextMessageEncodingElement, CustomTextMessageEncoder" />
            </bindingElementExtensions>
          </extensions>

    All the classes including the factory from the sample are in place and the project all compiles successfully. Any idea what I've done wrong?

    Thanks in advance

    Wednesday, February 19, 2014 12:34 PM

Answers

  • Ok, to perhaps help the next person who has this issue, the problem was the binding tag name "basicHttpBinding". It needed to be "customBinding":

            <customBinding>
              <binding name="MyWebServiceBinding">
                <customTextMessageEncoding encoding="utf-8" messageVersion="Soap11" />
                <httpTransport/>
              </binding>
            </customBinding>

    Who knew? Not me...
    Enjoy
    Monday, February 24, 2014 9:16 PM

All replies

  • Hi,

    >> It keeps throwing "Unrecognized element 'customTextMessageEncoding'" on the <binding...> tag when I now make the web service call.

    When meeting this error, please try to check the following msdn article to see if you have done something wrong.
    #How to use CustomTextMessageEncoder in wcf:
    http://msdn.microsoft.com/en-us/library/ms751486(v=vs.110).aspx .

    Also please try to enable the wcf tracing to find the cause.
    The following configuration taken from MSDN can be applied to enable tracing on your WCF service.

    <configuration>
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true" >
            <listeners>
                 <add name="xml"/>
            </listeners>
          </source>
          <source name="System.ServiceModel.MessageLogging">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
          <source name="myUserTraceSource"
                  switchValue="Information, ActivityTracing">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
            <add name="xml"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="Error.svclog" />
        </sharedListeners>
      </system.diagnostics>
    </configuration>
    Best Regards,
    Amy Peng

    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.

    Thursday, February 20, 2014 9:33 AM
    Moderator
  • Ok thanks for the reply. However that is the sample I've been using and I already had tracing on, (verbose). What I'm uncertain about is how .NET knows to use the new tag "customTextMEssagingEncoder". It's in the library dll subproject which is marked as referenced by the main project...just not confident that the XML parser has been told about it. I don't see that explained in the MSDN article, (or I'm just missing it). 
    Friday, February 21, 2014 12:17 PM
  • Ok, to perhaps help the next person who has this issue, the problem was the binding tag name "basicHttpBinding". It needed to be "customBinding":

            <customBinding>
              <binding name="MyWebServiceBinding">
                <customTextMessageEncoding encoding="utf-8" messageVersion="Soap11" />
                <httpTransport/>
              </binding>
            </customBinding>

    Who knew? Not me...
    Enjoy
    Monday, February 24, 2014 9:16 PM