WCF绑定问题

时间:2017-09-18 05:59:41

标签: c# web-services wcf

我的绑定有问题,我不知道如何解决它。我在服务器端,客户端正在使用此绑定:

<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
<httpModules>
  <add name="ApplicationInsightsWebTracking" 
type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, 
Microsoft.AI.Web"/>
</httpModules>
</system.web>
<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
multipleSiteBindingsEnabled="true"/>

<bindings>
  <customBinding>
    <binding name="pciBinding" receiveTimeout="00:05:00" 
sendTimeout="00:05:00">
      <textMessageEncoding messageVersion="Soap11WSAddressing10" 
writeEncoding="utf-8" />
      <httpTransport maxReceivedMessageSize="67108864" />
    </binding>
  </customBinding>
</bindings>

</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
  <remove name="ApplicationInsightsWebTracking"/>
  <add name="ApplicationInsightsWebTracking" 
type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, 
Microsoft.AI.Web"
    preCondition="managedHandler"/>
</modules>

<directoryBrowse enabled="true"/>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>

我也把它放在我的配置文件中,但异常仍然是相同的: 标题&#39;动作&#39;来自命名空间&#39; http://www.w3.org/2005/08/addressing&#39;此邮件的收件人不理解该邮件,导致邮件无法处理。此错误通常表示此消息的发送方已启用接收方无法处理的通信协议。请确保客户端绑定的配置与服务的绑定一致。

为了使这个有用,我需要做些什么?

1 个答案:

答案 0 :(得分:0)

您需要在配置中添加端点:

<system.serviceModel>
    <services>
        <service>
            <endpoint binding="customBinding" bindingConfiguration="pciBinding" name="MyEndpoint" behaviorConfiguration="myBehavior" contract="Your.Contract.Interface.With.Fullname" />
        </service>
    </services>
</system.serviceModel>

并且你需要给你的行为命名以在端点上绑定它,在这个例子中它被称为“myBehavior”。