Reputation: 11
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 searched the net for any issues on the 2 version but none found. Any help is highly appreciated. TIA
Upvotes: 1
Views: 7359
Reputation: 891
If you want to pass xml value within a soap message and you control both the server and the client (or at least you can instruct the client), why not base64 encode your xml. Then the parser will just see it as a normal string and not get confused.
Upvotes: 0
Reputation: 80
Yes and the answer is in soapval class.
Little messy but simple example is here. In quick - you have to wrap with this class any non-generic type, that means i.e. php array. Nesting of this wraps could of course happen but it's not against design.
Upvotes: 0
Reputation: 1745
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));
Upvotes: 0
Reputation: 5130
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 >, '<' for < either manually or using a function such as htmlentities()
Upvotes: 0