1

我正在开发一个 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>
4

0 回答 0