I am using NuSOAP to try to consume a Web Service built in Java. I have this code so far:
<?php
require_once('lib/nusoap.php');
$wsdl="http://localhost:8080/HelloWorldWS/sayHiService?WSDL";
$client=new nusoap_client($wsdl, 'wsdl');
$param='John';#array('name'=>'John');
echo $client->call('Hey', $param);
unset($client);
?>
but when the web page gets loaded I get a blank page nothing not even in the code and I really don't know why. Am I doing something wrong?
NuSOAP is a SOAP Toolkit for PHP that doesn't require PHP extensions.
The NuSOAP library is a collection of PHP classes that is used for sending and receiving SOAP messages using the HTTP protocol. The NuSOAP library can be downloaded from the Sourceforge link.
although NuSOAP is a very common PHP SOAP library, it's main use in PHP4 applications I think. because PHP5 has a built-in SOAP extension that is faster (because it is a compiled extension). I also recommend using Zend Framework SOAP library. but I remember I wanted to use some web service (not written by me, implemented in Java) and none of these SOAP clients worked, but the NuSOAP. and I really could not figure out why.
anyway, here is the thing that I did to use that web service back then:
$soapClient = new nusoap_client($wsdlFile, 'wsdl', '', '', '', '');
$soapClient->soap_defencoding = 'UTF-8';
$soapClient->debug_flag = false;
$soapError = $soapClient->getError();
if (! empty($soapError)) {
$errorMessage = 'Nusoap object creation failed: ' . $soapError;
throw new Exception($errorMessage);
}
// calling verifyT method, using 2 parameters.
$tResult = $soapClient->call( 'verifyT', array($param1, $param2) );
$soapError = $soapClient->getError();
if (! empty($soapError)) {
$errorMessage = 'SOAP method invocation (verifyT) failed: ' . $soapError;
throw new Exception($errorMessage);
}
if ($soapClient->fault) {
$fault = "{$soapClient->faultcode}: {$soapClient->faultdetail} ";
// handle fault situation
}
Don't use NuSoap. PHP has had a native soap client since version 5, which is far more stable, besides being faster.
.. when the web page gets loaded I get a blank page nothing not ..
That's probably a fatal error. Try checking the error logs to see what went wrong. Or set display_errors = on
Don't use NuSoap. PHP has had a native soap client since version 5
There are some good reasons to keep using NuSOAP on PHP5 :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With