Eri*_*ick 3 php soap wsdl web-services
我用google搜索并在stackoverflow中查看,但我还没有找到解决我的具体问题的方法.我一直在收到错误
SOAP-ERROR: Parsing WSDL: Couldnt load from "https://sampleurl.com/MerchantQueryService.asmx?WSDL" : failed to load external entity "https://sampleurl.com/MerchantQueryService.asmx?WSDL"
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用带有URL的SOAP API
https://sampleurl.com/MerchantQueryService.asmx?WSDL
Run Code Online (Sandbox Code Playgroud)
我在我的localhost上运行MAMP并使用godaddy共享主机,我已经尝试过两个与wsdl文件可以在这里找到
http://clemdemo.com/test.wsdl
Run Code Online (Sandbox Code Playgroud)
在PHP中,我使用下面的代码
error_reporting(-1);
ini_set('display_errors', 'On');
ini_set('soap.wsdl_cache_enabled', 0);
echo "<pre>";
try {
$url = "https://sampleurl.com/MerchantQueryService.asmx?WSDL ";
$headers = [
'Host: sampleurl.com',
'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;
}
Run Code Online (Sandbox Code Playgroud)
在我的MAMP localhost上,我有SOAP,openssl和curl.
此外,我尝试使用(发送请求)使用在线WSDL http://wsdlbrowser.com API,但是在使用PHP的代码上它失败了
小智 12
通常情况下,提供商忽略了他们的SSL证书,因此网站和服务最终会出现无效的证书 - 我怀疑这就是这种情况.
在此处禁用Kaii所述的证书验证,甚至更好地让您的提供商修复其证书.
您的代码可能/应该是这样的:
$url = "https://sampleurl.com/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);
Run Code Online (Sandbox Code Playgroud)