I am attempting to use PHP 5.2’s SoapServer functionality. I setup soapserv.php as shown below. But I am lost as to how I can call the ‘add’ function with a language other than PHP (without WSDL). I want to make calls to it with AJAX (jQuery). Any help would be greatly appreciated!
<?php
function add($a, $b) {
return $a + $b;
}
$soap = new SoapServer(
null,
array('uri' => 'http://example.com/projects/php/soapserv/')
);
$soap->addFunction("add");
$soap->handle();
?>
And my JavaScript looks like this (tried several ways though).
var req = $.post("http://example.com/projects/php/soapserv", {"add":{a: 1, b: 2}});
req.done(function(msg){
document.write(msg.responseText);
});
req.fail(function(msg){
document.write(msg.responseText);
});
Got it… Just had to change the post data to a soap envelope!