使用HTTPS的CustomTextMessageEncoder的WCF CustomBinding

时间:2013-03-11 18:38:10

标签: wcf https wcf-extensions

我正在开发一个WCF REST类型的服务,它将通过HTTPS上的POST(IIS上的ASP.NET 4.0)接受text / xml类型的文档。有人可以帮我web.config吗?我正在测试CustomTextMessageEncoder的示例代码来解析文档。我收到一个错误: “消息级安全性不支持手动寻址。配置绑定('CustomBinding','http://tempuri.org/')以使用传输安全性或不进行手动寻址。”

不幸的是,如果我关闭ManualAddressing,我会收到不同的错误。我不确定如何启用TransportSecurity,因为它是自定义绑定。

我正在做的web.config的主要部分是:

  <system.serviceModel>
    <services>
      <service name="MyApp.MyApp" behaviorConfiguration="MyAppBehavior" >
        <endpoint address="https://myURL/MyApp/" binding="customBinding" bindingConfiguration="newBinding" behaviorConfiguration="webEndpoint"  contract="MyApp.IMyApp" />
        <host>
          <baseAddresses>
            <add baseAddress="https://myURL/MyApp/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false" aspNetCompatibilityEnabled="true">
      <baseAddressPrefixFilters>
        <add prefix="https://myURL/MyApp/" />
      </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyAppBehavior" >
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="True" httpsGetUrl="https://myURL/MyApp/MyApp.svc/"  />
          <serviceDebug includeExceptionDetailInFaults="True"  />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="webEndpoint" >
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <extensions>
      <bindingElementExtensions>
        <add name="customTextMessageEncoding" type="Microsoft.Samples.CustomTextMessageEncoder.CustomTextMessageEncodingElement, CustomTextMessageEncoder" />
      </bindingElementExtensions>
    </extensions>
    <bindings>
      <webHttpBinding>
        <binding name="webHttpBinding">
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
      <customBinding>
        <binding name="newBinding" >
          <security authenticationMode="AnonymousForCertificate" />
          <customTextMessageEncoding messageVersion="Soap12WSAddressing10">
          </customTextMessageEncoding>
          <httpsTransport manualAddressing="true" requireClientCertificate="true" />
        </binding>
      </customBinding>
    </bindings>
  </system.serviceModel>

0 个答案:

没有答案