1

我有一个 WCF 服务,我在 IIS7 和 selfhost 中托管,并且使用默认的 serlizer 它在两者中都很好用。

运行 protobuf.net 端点时,它对 IIS7 主机非常有效,但是当对 selfhost 运行时,我只是在第一个服务方法中得到 null 作为请求?

我应该去哪里看?你需要什么来帮助我解决这个问题?

此致

编辑1:App.config(selfhost)

    <system.serviceModel>
  <diagnostics>
    <messageLogging logEntireMessage="true" logMalformedMessages="true"
      logMessagesAtTransportLevel="true" />
  </diagnostics>
  <extensions>
    <behaviorExtensions>
      <add name="protobuf" type="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net, Version=2.0.0.480, Culture=neutral, PublicKeyToken=257b51d87d2e4d67"/>
      <add name="customBehaviorExtension_Integration" type="MyApp.ServiceImplementation.CustomRequestInterceptorBehaviorExtension_Integration, MyApp.ServiceImplementation"/>
      <add name="customBehaviorExtension_ClientService" type="MyApp.ServiceImplementation.CustomRequestInterceptorBehaviorExtension_ClientService, MyApp.ServiceImplementation"/>
    </behaviorExtensions>
  </extensions>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  <behaviors>
    <serviceBehaviors>
      <behavior name="MyApp.ServiceImplementation.MyAppIntegration_Behavior">
        <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        <serviceDebug includeExceptionDetailInFaults="true"/>
        <serviceMetadata httpGetEnabled="true"/>
        <customBehaviorExtension_Integration/>
      </behavior>
      <behavior name="MyAppClientService.CustomValidator_Behavior">
        <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        <serviceDebug includeExceptionDetailInFaults="true"/>
        <serviceMetadata httpGetEnabled="true"/>
        <customBehaviorExtension_ClientService/>
        <serviceThrottling maxConcurrentCalls="2000" maxConcurrentSessions="2147483647" maxConcurrentInstances="2000"/>
        <serviceCredentials>
          <clientCertificate>
            <authentication certificateValidationMode="PeerOrChainTrust"/>
          </clientCertificate>
          <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyApp.ServiceImplementation.CustomUsernamePasswordValidator, MyApp.ServiceImplementation"/>
        </serviceCredentials>
        <serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="MyApp.ServiceImplementation.CustomServiceAuthorizationManager, MyApp.ServiceImplementation">
          <authorizationPolicies>
            <add policyType="MyApp.ServiceImplementation.CustomAuthorizationPolicy_ClientService, MyApp.ServiceImplementation"/>
          </authorizationPolicies>
        </serviceAuthorization>
      </behavior>
      <behavior name="MyApp.ServiceImplementation.HL7Service_Behavior">
        <serviceDebug includeExceptionDetailInFaults="true"/>
        <serviceMetadata httpGetEnabled="true" externalMetadataLocation="..\Schema\HL7\DIPS\IHl7Service.wsdl"/>
        <customBehaviorExtension_Integration/>
      </behavior>
    </serviceBehaviors>
    <endpointBehaviors>
      <behavior name="protoEndpointBehavior">
        <protobuf/>
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <services>
    <service behaviorConfiguration="MyApp.ServiceImplementation.MyAppIntegration_Behavior" name="MyApp.ServiceImplementation.MyAppIntegration">
      <endpoint binding="basicHttpBinding" bindingConfiguration="BasicMyAppIntegration" bindingNamespace="MyApp.ServiceImplementation" contract="MyApp.ServiceContracts.IMyAppIntegration"/>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8003/MyApp5Service/Integration"/>
        </baseAddresses>
      </host>
    </service>
    <service behaviorConfiguration="MyAppClientService.CustomValidator_Behavior" name="MyApp.ServiceImplementation.MyAppClientService">
      <endpoint binding="netTcpBinding" bindingConfiguration="netTcpRegular" address="Regular" bindingNamespace="http://MyApp.ServiceContracts/2007/11" contract="MyApp.ServiceContracts.IMyAppClientService"/>
      <endpoint binding="netTcpBinding" behaviorConfiguration="protoEndpointBehavior" bindingConfiguration="netTcpRegular" address="Proto" bindingNamespace="http://MyApp.ServiceContracts/2007/11" contract="MyApp.ServiceContracts.IMyAppClientService"/>

      <endpoint binding="netTcpBinding" bindingConfiguration="netTcpWindowMessageSecurity" address="Windows" bindingNamespace="http://MyApp.ServiceContracts/2007/11" contract="MyApp.ServiceContracts.IMyAppClientService"/>
      <host>
        <baseAddresses>
          <add baseAddress="net.tcp://localhost:8001/MyApp5Service/Client/"/>
          <add baseAddress="http://localhost:8002/MyApp5Service/Client"/>
        </baseAddresses>
      </host>
    </service>
    <service behaviorConfiguration="MyApp.ServiceImplementation.HL7Service_Behavior" name="MyApp.ServiceImplementation.HL7Service">
      <endpoint binding="basicHttpBinding" bindingConfiguration="BasicBindingHL7" contract="IHL7Service"/>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8004/MyApp5Service/Hl7"/>
        </baseAddresses>
      </host>
    </service>
  </services>
  <bindings>
    <netTcpBinding>
      <binding name="netTcpCertificate" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="1000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="200" maxReceivedMessageSize="2147483647">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
        <reliableSession ordered="true" inactivityTimeout="infinite" enabled="false"/>
        <security mode="TransportWithMessageCredential">
          <transport clientCredentialType="Certificate"/>
          <message clientCredentialType="UserName"/>
        </security>
      </binding>
      <binding name="netTcpWindowMessageSecurity" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="1000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="200" maxReceivedMessageSize="2147483647">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
        <reliableSession ordered="true" inactivityTimeout="infinite" enabled="false"/>
        <security mode="Message">
          <message clientCredentialType="Windows"/>
        </security>
      </binding>
      <!---->
      <binding name="netTcpRegular" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="1000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="200" maxReceivedMessageSize="2147483647">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
        <reliableSession ordered="true" inactivityTimeout="infinite" enabled="false"/>
        <security mode="None">
          <transport clientCredentialType="None"/>
        </security>
      </binding>
    </netTcpBinding>
    <customBinding>
      <binding name="UsernamePasswordOverHttp">
        <textMessageEncoding messageVersion="Soap11"/>
        <security authenticationMode="UserNameOverTransport" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" allowInsecureTransport="true"/>
        <httpsTransport/>
      </binding>
    </customBinding>
    <basicHttpBinding>
      <binding name="BasicMyAppIntegration" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
        <security mode="None"/>
      </binding>
      <binding name="BasicBindingHL7" allowCookies="true" closeTimeout="04:00:00" openTimeout="04:00:00" receiveTimeout="04:00:00" sendTimeout="04:00:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">

        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
        <security mode="None">
          <transport clientCredentialType="None"/>
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>
</system.serviceModel>
4

1 回答 1

2

看起来像是客户端的简单配置问题(单独发送);使用的一件有趣的事情(根本在客户端配置中)是protoEndpointBehavior定义在<endpointBehaviors>

<endpoint
  address="...(omitted).../Proto"
  behaviorConfiguration="BasicBehavior"
  ...(omitted)...
  name="SelfHostProto_RegularLogin"/>

如果我们将其更改BasicBehaviorprotoEndpointBehavior然后一切正常。消息被正确发送和接收。

于 2012-08-30T07:25:07.780 回答