如何解决如何在 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>
此网络服务正在使用中,并被其他 .NET 客户端成功使用,但这是我第一次尝试使用 PHP 来实现。 我也刚刚测试过,它适用于 jquery(现在我将使用它)。 老实说,我不明白我的绑定设置,但我记得我确实很难将它设置为我的 .NET 客户端正常工作
解决方法
你的WCF服务使用的绑定是webHttpBinding,所以使用soapClient调用wcf服务是不正确的。您需要构建一个 HTTP 请求来访问您的 WCF 服务。您可以参考这个链接来构建一个访问 WCF 服务的 HTTP 请求:HTTP Request
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。