[英]How can I enable WS-RM (version 1.2) with NuSOAP client
Can enable I enable WS-RM (version 1.2) with NuSOAP client just like below? 是否可以像下面那样启用我的NuSOAP客户端的WS-RM(1.2版)? I tried this, but I cannot receive data from the API.
我尝试了此操作,但无法从API接收数据。 Any ideas?
有任何想法吗? Thanks.
谢谢。
$client = new nusoap_client($api_link, array('reliable' => 1.2 , 'useWSA' => TRUE) );
Full Code: 完整代码:
try {
include_once 'WebServiceSOAP/lib/nusoap.php';
$api_link = 'https://www.my-api.com/MYAPI.svc/SSL?wsdl';
$acode = '###';
$uname = '###';
$ttype = '###';
$ccode = '###';
$hpass = '###';
//setting xml request to api
$credentials = '<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/" xmlns:ezr="http://schemas.datacontract.org/2004/07/EzremitAPI.Entities">
<soapenv:Header/>
<soapenv:Body>
<tem:GetLocalRates>
<!--Optional:-->
<tem:credentials>
<!--Optional:-->
<ezr:AgentCode>'.$acode.'</ezr:AgentCode>
<!--Optional:-->
<ezr:HashedPassword>'.$hpass.'</ezr:HashedPassword>
<!--Optional:-->
<ezr:Username>'.$uname.'</ezr:Username>
</tem:credentials>
<!--Optional:-->
<tem:payincurcode>'.$ccode.'</tem:payincurcode>
<!--Optional:-->
<tem:transferType>'.$ttype.'</tem:transferType>
</tem:GetLocalRates>
</soapenv:Body>
</soapenv:Envelope>';
//creating soap object
$client = new nusoap_client($api_link, array('cache_wsdl' => WSDL_CACHE_NONE, 'soap_version' => SOAP_1_2) );
$client->soap_defencoding = 'UTF-8';
$soapaction = "http://tempuri.org/IRateAPI/GetLocalRates";
$xmlobjs = $client->send($credentials, $soapaction);
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
exit();
}
//print_r($client);
print_r($xmlobjs);
}
catch(Exception $e) {
echo $e->getMessage();
}
?>
I'm not very good at PHP and SOAP. 我不太擅长PHP和SOAP。 Above code may have errors.
上面的代码可能有错误。 Could you please check the code and give me your comments.
您能否检查代码并给我您的评论。 I have made some amendments after searching Google.
搜索Google后,我做了一些修改。
Also, can I run this on PHP 5.4.42? 另外,我可以在PHP 5.4.42上运行它吗? When I run above code, I get below error now.
当我运行上面的代码时,我现在得到下面的错误。
Constructor error HTTP Error: Unsupported HTTP response status 415 Cannot process the message because the content type 'text/xml; 构造函数错误HTTP错误:不支持的HTTP响应状态415无法处理消息,因为内容类型为'text / xml;。 charset=UTF-8' was not the expected type 'application/soap+xml;
charset = UTF-8'不是预期的类型'application / soap + xml; charset=utf-8'.
charset = utf-8'。 (soapclient->response has contents of the response)
(soapclient-> response具有响应的内容)
If anyone is looking for the answer to my above question, I found the solution with the help from @Marcel. 如果有人在寻找我上述问题的答案,我在@Marcel的帮助下找到了解决方案。
The answer to the question: 问题的答案:
This code is wrong, don't use it. 此代码是错误的,请不要使用它。
$client = new nusoap_client($api_link, array('reliable' => 1.2 , 'useWSA' => TRUE) );
NuSoap client is outdated and not supporting to WS-RM. NuSoap客户端已过时,并且不支持WS-RM。 I had to use PHP inbuilt SOAP extension to get my project worked.
我必须使用PHP内置的SOAP扩展来使我的项目正常工作。
Full answer in here: SOAP Error in PHP: OperationFormatter encountered an invalid Message body 完整答案在这里: PHP中的SOAP错误:OperationFormatter遇到无效的消息正文
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.