php soapclient wsdl SOAP

编程入门 行业动态 更新时间:2024-10-22 02:59:06
本文介绍了php soapclient wsdl SOAP-ERROR:解析 WSDL:无法加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在 stackoverflow 中搜索并查看了此处,但我还没有找到解决我的具体问题的方法.我不断收到错误

SOAP-ERROR:解析 WSDL:无法从sampleurl/MerchantQueryService.asmx?WSDL"加载:无法加载外部实体sampleurl/MerchantQueryService.asmx?WSDL"

我正在尝试使用带有类似

的 URL 的 SOAP API

sampleurl/MerchantQueryService.asmx?WSDL

我在我的本地主机上运行 MAMP 并使用 Godaddy 共享主机,我已经尝试使用 wsdl 文件可以在这里找到

clemdemo/test.wsdl

在 PHP 中我使用下面的代码

error_reporting(-1);ini_set('display_errors', 'On');ini_set('soap.wsdl_cache_enabled', 0);echo "

";尝试 {$url = "sampleurl/MerchantQueryService.asmx?WSDL";$headers = ['主机:sampleurl','连接:保持活动','用户代理:PHP-SOAP/5.3.29','内容类型:文本/xml;字符集=utf-8','SOAPAction: "RequestTransaction"','内容长度:409'];$rq = [用户名" =>"username_here",密码" =>"password_here",referenceId" =>"3455566694",msisdn"=>"346774313"];尝试 {$cient = 新 SoapClient($url,['soap_version' =>肥皂_1_2,'例外' =>1、'cache_wsdl' =>WSDL_CACHE_NONE,'跟踪' =>1、'stream_context' =>stream_context_create(array('http' => array('header' => $headers)))]);打印_r($cient);}赶上(SoapFault $e){echo "\n故障代码:".$e->故障代码;echo "\nFault String: ".$e->faultstring;}

在我的 MAMP 本地主机上,我有 SOAP、openssl 和 curl.

另外,我尝试使用(发送请求)到带有在线 WSDL wsdlbrowser 的 API有效,但在使用 PHP 的代码上失败

解决方案

供应商经常会忽略他们的 SSL 证书,因此站点和服务最终会使用无效的证书 - 我怀疑这里就是这种情况.

禁用证书验证,如由 Kaii 在这里 或更好地获得您的提供商修复他们的证书.

您的代码可以/应该是这样的:

$url = "sampleurl/MerchantQueryService.asmx?WSDL ";$context = stream_context_create(数组('ssl' =>大批('verify_peer' =>错误的,'verify_peer_name' =>错误的,'allow_self_signed' =>真的)));$rq = [用户名" =>"username_here",密码" =>"password_here",referenceId" =>"3455566694",msisdn"=>"346774313"];$service = new SoapClient($url, array('stream_context' => $context));$service->RequestTransaction($rq);

I have googled and looked here in stackoverflow but I have not found a solution to my specific problem. I keep getting the error

SOAP-ERROR: Parsing WSDL: Couldnt load from "sampleurl/MerchantQueryService.asmx?WSDL" : failed to load external entity "sampleurl/MerchantQueryService.asmx?WSDL"

I am trying to use a SOAP API with a URL like

sampleurl/MerchantQueryService.asmx?WSDL

I am running MAMP on my localhost and using godaddy shared hosting, I have tried on both with the wsdl file can be found here

clemdemo/test.wsdl

In PHP I use the code below

error_reporting(-1); ini_set('display_errors', 'On'); ini_set('soap.wsdl_cache_enabled', 0); echo "<pre>"; try { $url = "sampleurl/MerchantQueryService.asmx?WSDL "; $headers = [ 'Host: sampleurl', 'Connection: Keep-Alive', 'User-Agent: PHP-SOAP/5.3.29', 'Content-Type: text/xml; charset=utf-8', 'SOAPAction: "RequestTransaction"', 'Content-Length: 409']; $rq = [ "userName" => "username_here", "passWord" => "password_here", "referenceId" => "3455566694", "msisdn" => "346774313"]; try { $cient = new SoapClient($url, [ 'soap_version' => SOAP_1_2, 'exceptions' => 1, 'cache_wsdl' => WSDL_CACHE_NONE, 'trace' => 1, 'stream_context' => stream_context_create(array('http' => array('header' => $headers))) ]); print_r($cient); } catch (SoapFault $e) { echo "\nFault Code: ".$e->faultcode; echo "\nFault String: ".$e->faultstring; }

On my MAMP localhost i have SOAP,openssl and curl.

ALSO, I tried using (sending request) to the API with an online WSDL wsdlbrowser it WORKS but on code using PHP it fails

解决方案

It often happens that providers neglect their SSL certificates and hence the sites and services end up having an invalid certificates - I suspect this is the case here.

Disabling the certificate validation as described by Kaii here or even better get your provider to fix their certificate.

Your code could/should then be something like:

$url = "sampleurl/MerchantQueryService.asmx?WSDL "; $context = stream_context_create(array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) )); $rq = ["userName" => "username_here", "passWord" => "password_here", "referenceId" => "3455566694", "msisdn" => "346774313"]; $service = new SoapClient($url, array('stream_context' => $context)); $service->RequestTransaction($rq);

更多推荐

php soapclient wsdl SOAP

本文发布于:2023-05-28 12:31:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/320961.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:词库加载错误:Could not find file &#039;D:\淘小白 高铁采集器win10\Configuration\Dict_Sto

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!