php - 如何在 PHP 中使用 WCF 服务?
问题描述
我有一个使用 GET 函数运行的简单 WCF 服务。当我在网络浏览器中调用它时。它工作正常。
当我尝试以下 PHP 调用时:
define('NEWLINE' , "< br />\n");
$wsdl = "https://www.***.info/Webservices/WCF/***.svc?wsdl";
Line 727: $soapClient= new SoapClient($wsdl,array('cache_wsdl' => 0));
$result = $soapClient->TestForPHP();
$soapClient = null;
echo "WCF service Return value: "." "."($result->getMessageResult)". NEWLINE;
我在调试中收到以下错误:
PHP Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Could not find any usable binding services in WSDL. in /home/customer/www/staging9.***.com/public_html/wp-content/themes/hello-theme-child-master/functions.php:727
这是我的绑定在我的 web.config 文件中的样子:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="inculdeExceptionDetails">
<serviceDebug includeExceptionDetailInFaults="true " />
</behavior>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="https">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<protocolMapping>
<add binding="webHttpBinding" scheme="http" />
<add binding="webHttpBinding" scheme="https" bindingConfiguration="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
这个 web 服务正在被其他 .NET 客户端成功使用,但这是我第一次尝试使用 PHP。我也刚刚测试过,它可以在 jquery 中工作(现在我将使用它)。老实说,我不了解我的绑定设置,尽管我记得我确实很难将其设置为适用于我的 .NET 客户端
解决方案
你的WCF服务使用的绑定是webHttpBinding,所以使用soapClient调用wcf服务是不正确的。你需要构造一个HTTP请求来访问你的WCF服务。你可以参考这个链接构造HTTP请求来访问WCF服务:HTTP Request
推荐阅读
- azure - 通过自定义角色密钥库的 ARM 模板进行蓝图部署
- layout - SwiftUI 中的 Selfsize 网格项
- c# - C# 复制
来自其他班级 - paypal - 从我的客户电子邮件地址获取 PayPal 客户 ID
- c# - FileNotFoundException WpfAnimatedGif
- flutter - Flutter中Expandable中flex的默认值是多少?
- react-native - 如何在 ReactNative 中将多个 FlatList 项目发送到另一个屏幕?
- netsuite - 无法在 .each() 方法中更新 Netsuite 中的子列表字段
- reporting-services - 如何在 SSRS 报表生成器模板上的值之后显示文本?
- sql - 重写查询以使用分析函数