views:

146

answers:

2

Good day,

I am having trouble passing an xml in nusoap.

sample: I pass this xml <test>123</test>
The nusoap response is test123/test

The greater than and less than sign is removed.

This is my code for the server:


require_once('nusoap/nusoap.php');
$server = new nusoap_server; // Create server instance

$server->configureWSDL('demows','http://example.org/demo');

$server->register('myFunction',
array("param"=>"xsd:string"), // input
array("result"=>"xsd:string"), // output
'http://example.org/demo'
);

function myFunction($parameters) {
return $parameters;
}

// Use the request to try to invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA: '';
$server->service($HTTP_RAW_POST_DATA);


This is my code for the client:


require_once('nusoap/nusoap.php');

$client = new nusoap_client('http://localhost/nusoap/ws.php?wsdl', true);

$clientparam = '<test>123</test>';

$result = $client->call('myFunction',
array('param'=>$clientparam)
);

print_r($result);


*Note that the above code is working on PHP Version 5.3.0 but NOT on PHP Version 5.2.0-8+etch13 which is the one on our production is using.

I've search the net for any issues on the 2 version but none found. Any help is highly appreciated. TIA

A: 

I don't know nusoap at all, but it sounds like your entities are being discarded. It might be worth controlling the entities at either end, for instance by changing '>' for &gt;, '<' for &lt; either manually or using a function such as htmlentities()

Woody
already tried that but all ampersands are being remove.> becomes gt;< becomes lt;thus I still don't have the correct xml format
roel
Definitely seems like it is removing entities then. Do you have any control on the other side, ie, could you not use some non entity characters (maybe like [test]123[/test]) and reconstruct on the other side?.There are a few reports of similar with libxml stripping entities, such as this: http://bugs.php.net/bug.php?id=45996 which was fixed in 5.2.9
Woody
sounds like what you are seeing:http://drupal.org/node/347298
Woody
A: 

Not sure if you're using a different version of nusoap than me, but I've been using the proxy, which seems to be working. I also instantiate the client with soapclient rather than nusoap_client (hadn't seen that before):

 $client = new soapclient('http://localhost/nusoap/ws.php?wsdl', true);
 $proxy = $client->getProxy();
 $response = $proxy->call("myfunction", array('test' => 123));
Sean Nilan