Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuSOAP PHP Web Service

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?

like image 388
Tsundoku Avatar asked Apr 11 '09 01:04

Tsundoku


People also ask

What is NuSOAP in Web services?

NuSOAP is a SOAP Toolkit for PHP that doesn't require PHP extensions.

What is NuSOAP PHP?

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.


3 Answers

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
}
like image 131
farzad Avatar answered Oct 22 '22 00:10

farzad


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

like image 40
troelskn Avatar answered Oct 22 '22 00:10

troelskn


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 :

  • NuSOAP generate a list of methods when you GET the page
  • NuSOAP generate the WSDL "on the fly" a really useful feature that is not provided by native implementation of SOAP in PHP 5
like image 4
Pico Avatar answered Oct 22 '22 00:10

Pico