[英]Change EndPoint to NuSoap Client
English is not my native language so please be patient. 英语不是我的母语,所以请耐心等待。
I need to report the status of some mail deliverys to another company trough WebService. 我需要通过WebService向其他公司报告某些邮件传递的状态。 I'm using PHP+NuSoap, I'm new to PHP and this library help me to keep it simple, my code looks like this:
我正在使用PHP + NuSoap,我是PHP的新手,此库可帮助我保持其简单性,我的代码如下所示:
require_once '../nusoap/lib/nusoap.php';
Class Cliente{
var $server;
public function __construct(){
$this->server = 'https://the-other-company.com/services/PksiryacwebMgrTarjetasSubsi?wsdl';
}
function client_process($data){
$cliente = new nusoap_client($this->server,'wsdl','','','','');
$err = $cliente->getError();
if ($err) { echo 'Error en Constructor' . $err ; }
$response = $cliente->call('prwebActualizaCorresponden',$data,'','', false,true); //OK
return $response;
}
}
Where $data
is an array of strings and the WebService Server is suposed to return a response (always), but instead doesn't reply anything. 其中
$data
是字符串数组,WebService Server应该返回(始终)返回响应,但不回复任何内容。
When I called the WebService administrator, he told me that test it using SoapUI, then I find the problem is with the WSDL, because is pointing to an private IP addres (172.20.8.152) which can only be accesed from inside the other company LAN, instead the IP I was told to work (the-other-company.com). 当我打电话给WebService管理员时,他告诉我使用SoapUI对其进行测试,然后发现WSDL存在问题,因为它指向只能从其他公司LAN内部访问的私有IP地址(172.20.8.152)。 ,而是告诉我要使用的IP(the-other-company.com)。
<wsdl:service name="PksiryacwebMgr_Tarjetas_SubsiService">
<wsdl:port binding="impl:PksiryacwebMgr_Tarjetas_SubsiSoapBinding" name="PksiryacwebMgr_Tarjetas_Subsi">
<wsdlsoap:address location="http://172.20.8.152/services/PksiryacwebMgrTarjetasSubsi"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
In SoapUI this problem is easy to tackle setting another EndPoint with the right IP, but how to do this in NuSoap? 在SoapUI中,这个问题很容易解决,用正确的IP设置另一个EndPoint ,但是如何在NuSoap中做到这一点呢?
Edit: A workaround would be to make my own wsdl/xml, but that's not the idea. 编辑:一种解决方法是制作我自己的wsdl / xml,但这不是主意。
Thanks in advance. 提前致谢。
Use the function setEndpoint, it's defined arround the line 7873 of nusoap.php: 使用函数setEndpoint,它在nusoap.php的7873行周围定义:
/**
* sets the SOAP endpoint, which can override WSDL
*
* @param string $endpoint The endpoint URL to use, or empty string or false to prevent override
* @access public
*/
function setEndpoint($endpoint)
{
$this->debug("setEndpoint(\"$endpoint\")");
$this->forceEndpoint = $endpoint;
}
In your test code could be used by this way: 在您的测试代码中可以通过以下方式使用:
require_once '../nusoap/lib/nusoap.php';
Class Cliente{
var $server;
var $endPoint;
public function __construct(){
$this->server = 'https://the-other-company.com/services/PksiryacwebMgrTarjetasSubsi?wsdl';
$this->endPoint = 'http://172.20.8.152/services/PksiryacwebMgrTarjetasSubsi';
}
function client_process($data){
$cliente = new nusoap_client($this->server,'wsdl','','','','');
$cliente->setEndpoint($this->endPoint);
$err = $cliente->getError();
if ($err) { echo 'Error en Constructor' . $err ; }
$response = $cliente->call('prwebActualizaCorresponden',$data,'','', false,true); //OK
return $response;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.