Jump to content

Recommended Posts

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);
}

Link to comment
https://forums.phpfreaks.com/topic/238970-soap-web-service-and-jqueryajax/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.