1

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.

3
  • Are you required to use nusoap? if not, and if you are using php 5, try using php's inbuilt soap functions (soap_client)..it has better error reporting and is really much more stable than nusoap which was meant for php 4.. Commented Sep 27, 2012 at 2:42
  • @Raidenace: how do I send a raw XML with PHP5? I tried but it didn't work as I don't know, what I am supposed to write as "Location" and "URI". In my question, you can see what the two addresses are. But what about namespace? The DHL documentation is pretty bad. Commented Sep 27, 2012 at 2:48
  • I have added an answer with a sample working code against the WDL you posted. Check it out..hope it helps! Commented Sep 27, 2012 at 3:14

2 Answers 2

3

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
        )

)
Sign up to request clarification or add additional context in comments.

5 Comments

There is one question more: how do I send my XML request?
Do you mean how you submit the request to the web service? If you have the wsdl for the webservice, all you need to do is just pass it to the soap_client. The soap_client will automatically figure out the endpoint and all other details from a correct WSDL url
do you know the function name to generate batch labels and the wsdl url for the web service that contains that function?
createShipmentDD, as I suppose
Use the code I have above, replace $client->getVersion(); with $client->createShipmentDD();. As its arguments pass an array of all the fields you need to provide to the webservice
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.