none
Visual Studio generates wrong proxy and client config for WCF Service Host with customBinding RRS feed

  • Question

  • Hi,

    I have  a simple WCF test service.

    The serviceModel configuration for the looks like this:

     <system.serviceModel>
        <bindings>
          <customBinding>
            <binding name="NewBinding0">
              <byteStreamMessageEncoding>
                <readerQuotas maxDepth="10" maxStringContentLength="10000" maxArrayLength="10000"
                  maxBytesPerRead="1000" maxNameTableCharCount="200" />
              </byteStreamMessageEncoding>
              <tcpTransport />
            </binding>
          </customBinding>
        </bindings>
        <diagnostics>
          <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
        </diagnostics>
        
        <services>
          <service name="WcfServiceLibrary2.Service1">
            <endpoint address="mex" binding="mexHttpBinding" name="mexName"
              contract="IMetadataExchange" />
            <endpoint address="net.tcp://localhost:8734/WcfServiceLibrary2/Service1.svc"
              binding="customBinding" bindingConfiguration="NewBinding0" name="tcpName"
              bindingName="" contract="WcfServiceLibrary2.IService1" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary2/Service1/" />
              </baseAddresses>
            </host>
          </service>
        </services>
        
        
        <behaviors>
          <serviceBehaviors>
            <behavior name="">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    

    However the auto generated client side serviceModel looks like this:

        <system.serviceModel>
    
            <bindings>
                <customBinding>
                    <binding name="tcpName">
                        <textMessageEncoding messageVersion="Soap12" />
                        <tcpTransport />
                    </binding>
                </customBinding>
            </bindings>
            <client>
                <endpoint address="net.tcp://localhost:8734/WcfServiceLibrary2/Service1.svc"
                    binding="customBinding" bindingConfiguration="tcpName" contract="ServiceReference2.IService1"
                    name="tcpName" />
            </client>
        </system.serviceModel>

    Note the Encoding has changed to from byteStreamMessageEncoding to textMessageEncoding.

    When I test the service with WCF Test Client, I get the error "Addressing Version 'AddressingNone (http://schemas.microsoft.com/ws/2005/05/addressing/none)' does not support adding WS-Addressing headers."

    The error message makes sense in considering the client is mis-configured. I could manually modify the client side configuration, but I don't know how to give that to the WCF Test Client.

    When I run my own test client code, I get a NullReferenceException creating the Channel

       at System.Text.UTF8Encoding.GetByteCount(String chars)
       at System.ServiceModel.Channels.EncodedFramingRecord..ctor(FramingRecordType recordType, String value)
       at System.ServiceModel.Channels.EncodedContentType.Create(String contentType)
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.CreatePreamble()
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel..ctor(ChannelManagerBase factory, IConnectionOrientedTransportChannelFactorySettings settings, EndpointAddress remoteAddresss, Uri via, IConnectionInitiator connectionInitiator, ConnectionPool connectionPool, Boolean exposeConnectionProperty, Boolean flowIdentity)
       at System.ServiceModel.Channels.ConnectionOrientedTransportChannelFactory`1.OnCreateChannel(EndpointAddress address, Uri via)
       at System.ServiceModel.Channels.ChannelFactoryBase`1.InternalCreateChannel(EndpointAddress address, Uri via)
       at System.ServiceModel.Channels.ServiceChannelFactory.ServiceChannelFactoryOverDuplexSession.CreateInnerChannelBinder(EndpointAddress to, Uri via)
       at System.ServiceModel.Channels.ServiceChannelFactory.CreateServiceChannel(EndpointAddress address, Uri via)
       at System.ServiceModel.Channels.ServiceChannelFactory.CreateChannel(Type channelType, EndpointAddress address, Uri via)
       at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
       at System.ServiceModel.ClientBase`1.CreateChannel()
       at System.ServiceModel.ClientBase`1.CreateChannelInternal()
       at System.ServiceModel.ClientBase`1.get_Channel()
       at ConsolWCFTestApp.ServiceReference2.Service1Client.GetXSDFiles(String path) in c:\Users\malley\Documents\Visual Studio 2013\Projects\WcfService1\ConsolWCFTestApp\Service References\ServiceReference2\Reference.cs:line 127
       at ConsolWCFTestApp.Program.Main(String[] args) in c:\Users\malley\Documents\Visual Studio 2013\Projects\WcfService1\ConsolWCFTestApp\Program.cs:line 14
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

    Any suggestions much appreciated.

    Martin


    Friday, April 17, 2015 3:58 PM

Answers

  • Hi Martin00,

    I have tested your code in my side and I can meet the same exception as you.

    >>"Addressing Version 'AddressingNone (http://schemas.microsoft.com/ws/2005/05/addressing/none)' does not support adding WS-Addressing headers."

    Based the above exception, I try to use the following config:

    <textMessageEncoding messageVersion="Soap12" />

    Instead of this config code:

    <byteStreamMessageEncoding>
       <readerQuotas maxDepth="10" maxStringContentLength="10000" maxArrayLength="10000"
                  maxBytesPerRead="1000" maxNameTableCharCount="200" />
    </byteStreamMessageEncoding>-->

    After that it works fine as following:

    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.


    Monday, April 20, 2015 8:37 AM
    Moderator