shredding shredding - 5 months ago 19
PHP Question

What's the syntax for oop nusoap_client call?

I don't find the syntax for an object oriented nusoap_client call:

What's the correct syntax if I registered a class method to the server. I know the code for the server but fail to implement the correct client.

I have this server:

<?php

require_once "lib/nusoap.php";
require_once 'SampleData.php';

class SoapServer {

protected $server;

public function __construct() {

$this->server = new soap_server();
$server->register("SampleData.getSampleData");
$server->service($HTTP_RAW_POST_DATA);

}
}
?>


How do I call this from my SoapClient?

$result = $this->client->call("SampleData.getSampleData", array("category" => "sample"));


Seems not to work.

Ing Ing
Answer

I would avoid using SoapServer as a class name, may conflict with the standard extension (PHP Manual SoapServer).

Why are you wrapping soap_server with SoapServer anyway? Instead try:

$server = new soap_server();
$server->register("SampleData.getSampleData");
$server->service($HTTP_RAW_POST_DATA);

Client call should be like this:

$client = new soapclient('URL');
$result = $client->call("SampleData.getSampleData", array("category" => "sample"));
print_r($result);