NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Access Java 1.6 Web service using php client

Joined: 05 Jan 2009
Posts: 1
Reply with quote
We have written web service in Java 1.6 using JAX-WS. We need to call the methods from this web service using PHP Nusoap library.

In Java 1.6; we use Endpoint.publish method to publish the web service. Hence we dont require any container(so we are using Java1.6 which internally supports HTTP server) .

The PHP client code can parse the WSDL generated by Java code but when a method is called PHP client receives Null Pointer exception (fault).

Please help me in solving this problem.

Java Code:
package example;
import javax.jws.WebService;
import javax.jws.WebService;
import java.util.*;

public class Calculator {

public void add() {
int a=10;
//System.out.println("Add Method call");
//return a+b;

public static void main(String[] args){
// create and publish an endpoint
Calculator calculator = new Calculator();
Endpoint endpoint = Endpoint.publish("http://localhost:9999/calculator", calculator);

PHP code:

error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Pull in the NuSOAP code

$client = new soapclient('http://localhost:9999/calculator?wsdl', true);
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
// At this point, you know the call that follows will fail
// Call the SOAP method

$result = $client->call('add');

if ($client->fault) {
echo '<h2>Fault</h2><pre>';
echo '</pre>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
// Display the result
echo '<h2>Result</h2><pre>';
echo '</pre>';
// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
// Display the debug messages
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
View user's profileFind all posts by sheetal.nikamSend private message
Access Java 1.6 Web service using php client
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

 Reply to topic