简体   繁体   中英

php soap empty output

I'm an experienced PHP programmer but I have actually no clue about SOAP. Now I must use it because my customer needs an automatic generating of DHL batch labels. 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). My PHP code goes like:

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).

Please help.

When using soap_client you do not need to pass raw XML . Instead you look at the WSDL and decide which web service function you want to call, and what parameters it needs. 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). Then use this soap client object to call whichever web service function you want to call. 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. 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:

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

)

Does the web server respond with a status 200? You said you get an empty response right?

Use this free GUI tool (http://webservicestudio.codeplex.com/) to make webservice call and visualize. You can easily load up the WSDL and start making calls.

By the way working 2 jobs and study is good stuff man! Keep it up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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