在PHP中提取SOAP特定值并返回

时间:2017-03-23 18:41:08

标签: soap soap-client

我是SOAP UI的新手,所以有什么方法可以从SOAP UI中提取特定值并在PHP中返回我想从这个Courier服务跟踪SOAP API中提取数据并在PHP中显示

SOAP API:http://webapp.tcscourier.com/codapi/Service1.asmx SOAP请求:http://webapp.tcscourier.com/codapi/Service1.asmx?op=GetCNDetailsByReferenceNumber

非常感谢任何帮助。

提前致谢。

1 个答案:

答案 0 :(得分:0)

我认为您可能想要做的是:

首先启动与远程soap-Server的连接,因此需要启动客户端

$client = new SoapClient('http://webapp.tcscourier.com/codapi/Service1.asmx?WSDL');

由于它是一个公共API,因此您不需要登录凭据

然后你要调用远程方法,例如getAllCities并将响应存储在变量中;

$response = $client->getAllCities();

现在您可以查看结果:

var_dump($response);

为确保没有错误,您可以将上面的代码放在try...error

$client = new SoapClient('http://webapp.tcscourier.com/codapi/Service1.asmx?WSDL');
try {

  $response = $client->getAllCities();

} catch (SoapFault $e) {

 var_dump($e);    

} 

HTH - 最好的问候, 路波