php - 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 服务
有人知道如何避免这种情况吗?
预先感谢, 问候,
解决方案
推荐阅读
- flutter - 添加 Firestore 文档时出现 PlatformException 错误(java.lang.IllegalArgumentException:无效数据。不支持嵌套数组)
- html - CSS 弹性布局
- c - 自由函数的动态内存问题。应用程序在堆缓冲区结束后写入内存
- python - Python:通过基于搜索的索引页面进行抓取
- sql - 过滤自联接并仅包含与嵌套联接不匹配的行
- python - 在 Django 中渲染变量时遇到问题
- active-directory - WSO2 集成器 6.6.0 活动目录登录
- postgresql - PostgreSQL 与版本 12 和 13 混淆
- reactjs - Graphql 错误:仅在 Android 中网络请求失败
- c# - MVC 发布请求 - 最大数量 IEnumerable 中的对象
捆绑?