简体   繁体   English

php soap空输出

[英]php soap empty output

I'm an experienced PHP programmer but I have actually no clue about SOAP. 我是一名经验丰富的PHP程序员,但我实际上并不知道SOAP。 Now I must use it because my customer needs an automatic generating of DHL batch labels. 现在我必须使用它,因为我的客户需要自动生成DHL批处理标签。 I need some simple and effective help. 我需要一些简单而有效的帮助。

So I send a raw XML request to DHL, I have copied the message from their sample programm but I get always an empty result (no error). 所以我向DHL发送了一个原始XML请求,我已经从他们的示例程序中复制了该消息,但我总是得到一个空结果(没有错误)。 My PHP code goes like: 我的PHP代码如下:

require_once('nusoap/lib/nusoap.php');

$endpoint = "https://test-intraship.dhl.com/intraship.57/jsp/Login_WS.jsp";

$client = new nusoap_client($endpoint, false);

$msg = $client->serializeEnvelope("
<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\"
 xmlns:cis=\"http://dhl.de/webservice/cisbase\" xmlns:de=\"http://de.ws.intraship\">
<soap:Header>
<cis:Authentification><cis:user>bzalewski</cis:user>

(...) 

");

$result=$client->send($msg, $endpoint);

echo $result;

As said, the message is just copied so it must be OK. 如上所述,消息只是被复制,所以一定是好的。 I tried alternatively with another endpoint: http://test-intraship.dhl.com/ws/1_0/ISService/DE.wsdl , but also no result (no error). 我尝试了另一个端点: http//test-intraship.dhl.com/ws/1_0/ISService/DE.wsdl ,但也没有结果(没有错误)。

Please help. 请帮忙。

When using soap_client you do not need to pass raw XML . 使用soap_client您不需要传递原始XML Instead you look at the WSDL and decide which web service function you want to call, and what parameters it needs. 相反,您查看WSDL并确定要调用哪个Web服务函数,以及它需要哪些参数。 Then you create a soap client object, by passing the wsdl url and whether you want tracing or not (it helps to debug and stuff). 然后通过传递wsdl url以及是否要跟踪来创建一个soap客户端对象(它有助于调试和填充)。 Then use this soap client object to call whichever web service function you want to call. 然后使用此soap客户端对象来调用要调用的任何Web服务函数。 If there are parameters needed for the function call, pass them as an array. 如果函数调用需要参数,请将它们作为数组传递。 I have posted a sample code below which uses the WSDL you provided and calls its getVersion function. 我在下面发布了一个示例代码,该代码使用您提供的WSDL并调用其getVersion函数。 Note that this function does not need arguments so I am not passing anything. 请注意,此函数不需要参数,因此我没有传递任何内容。 Hope this helps you get started.. 希望这有助于您入门..

<?
$client = new SoapClient('http://test-intraship.dhl.com/ws/1_0/ISService/DE.wsdl', array('trace' => 1));
$res = $client->getVersion();
print_r($res); 
?>

This returns following value from the DHL web service: 这将从DHL Web服务返回以下值:

stdClass Object
(
    [Version] => stdClass Object
        (
            [majorRelease] => 1
            [minorRelease] => 0
            [build] => 14
        )

)

Does the web server respond with a status 200? Web服务器是否以状态200响应? You said you get an empty response right? 你说你得到一个空洞的回答吧?

Use this free GUI tool (http://webservicestudio.codeplex.com/) to make webservice call and visualize. 使用这个免费的GUI工具(http://webservicestudio.codeplex.com/)进行Web服务调用和可视化。 You can easily load up the WSDL and start making calls. 您可以轻松加载WSDL并开始拨打电话。

By the way working 2 jobs and study is good stuff man! 顺便说一下,工作2个工作和学习是好东西! Keep it up. 保持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM