chapp77 Posted June 10, 2011 Share Posted June 10, 2011 I have a PHP SOAP web service acting as a relay to call cross domain web services. The problem I'm having is calling my local PHP web service methods from JavaScript (using JQuery/Ajax). I want to call a specific method in my web service; e.g. "LoginToAccount"; I'm NOT interested in appending params in the url and then figuring out which method to call... This is very straight forward in .NET (mywebservice.asmx/LoginToAccount") but can't figure it out how to get this to work in PHP. I continually get a "500 Internal Server Error" of "Bad Request": Bad Request Here is my PHP code: <?php function LoginToAccount($email, $passCodeHash) { //...code calling cross-domain web services return $jsonEncodedResponse; } function CreateAccount($email, $passCodeHash){ //...code calling cross-domain web services return $jsonEncodedResponse; } $server = new SoapServer(null, array('uri' => "http://www.myurl/webservices/")); $server->addFunction('LoginToAccount'); $server->addFunction('CreateAccount'); $server->handle(); ?> Here is my javascript: function AjaxCall() { $.ajax({ type: "POST", url: "phpRelay.php/LoginToAccount", data: "{email : '[email protected]', passCodeHash: '12345'}", contentType: "application/json", dataType: "json", success: succeeded, error: queryError }); } function succeeded(data, textStatus, request) { var result = $.parseJSON(data.d); } function queryError(request, textStatus, errorThrown) { alert(request.responseText, textStatus + " " + errorThrown); } Quote Link to comment https://forums.phpfreaks.com/topic/238970-soap-web-service-and-jqueryajax/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.