首页 > 解决方案 > wshttpbinding 和 custombinding 不适用于soapClient PHP

问题描述


我无法在 PHP 中使用 TransportWithMessageCredential clientCredentialType 用户名连接到 WCF 服务的 SoapClient。
SoapClient 说:
无法处理消息,因为内容类型 'application/soap+xml; 字符集=utf-8;action="http://tempuri.org/ISecurityService/GetDocuments"' 不是预期的类型 'text/xml; 字符集=utf-8'。

这是我的 web.config 代码

<bindings>

  <wsHttpBinding>
    <binding name="wsSecureBinding">
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="UserName" />
      </security>
    </binding>
  </wsHttpBinding>
  <basicHttpsBinding>
    <binding name="BasicHttpsBinding_IService" closeTimeout="00:10:00"
      openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
      textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
      messageEncoding="Text">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpsBinding>
</bindings>

<services>
  <service
    name="Middleware.Services.SecurityService"
    behaviorConfiguration="ServiceWithMetaData">
    <endpoint name="wsSecureService"
              address=""
              binding="wsHttpBinding"
              bindingConfiguration="wsSecureBinding"
              contract="Middleware.Interfaces.ISecurityService"/>
  </service>
</services>

这是我在 PHP https://pastebin.com/ctVEKX6w中的代码

我的代码基于两个链接:
如何使用 WCF Web 服务,该服务使用 PHP 页面的自定义用户名验证?

[使用 PHP 连接到受 WS-Security 保护的 Web 服务

[3]:使用 PHP 连接到受 WS-Security 保护的 Web 服务

有人知道如何避免这种情况吗?
预先感谢, 问候,

标签: phpsoapweb-configsoap-clientwshttpbinding

解决方案


推荐阅读