5

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?

diestl
  • 2,020
  • 4
  • 23
  • 37
Tsundoku
  • 9,104
  • 29
  • 93
  • 127

6 Answers6

8

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
}
farzad
  • 8,775
  • 6
  • 32
  • 41
4

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
Pico
  • 71
  • 1
4

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

troelskn
  • 115,121
  • 27
  • 131
  • 155
  • 3
    I disagree. The inbuilt PHP SoapClient has issues and unresolved bugs. Like this one >> http://bugs.php.net/bug.php?id=48216&thanks=3 that prevents it from working at all. – Ahi Tuna Feb 03 '11 at 17:18
1

Yes, you're doing something wrong. It's hard to know what based on a blank page, but I'd start with this line, which doesn't look like valid PHP:

$param='John';#array('name'=>'John');

"#" does not start a comment in PHP; "//" does

If fixing that still results in a blank page, turn on error reporting and/or add more output throughout to see what exactly is happening.

Scott Reynen
  • 3,530
  • 18
  • 17
0

I was just facing the same problem.

Using include_once instead of require_once resolved the blank page problem. This is not the perfect solution of course, because of this: Difference between require, include and require_once?

Community
  • 1
  • 1
Mohamed Khamis
  • 7,731
  • 10
  • 38
  • 58
0

Please verify the HTML generated by the server in your browser. In my case, the result contained XML tags, so the browser could not properly display the information.

Jacob
  • 77,566
  • 24
  • 149
  • 228