About Web service ,how to use Ajax to call a specific member function of a class?
        Posted  
        
            by 
                Liu chwen
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Liu chwen
        
        
        
        Published on 2013-10-24T03:48:53Z
        Indexed on 
            2013/10/24
            3:53 UTC
        
        
        Read the original article
        Hit count: 240
        
I'm trying to build a web service by PHP.
In my case, I called the getINFO(), but the return value on client side always null. Have no idea to solve this problem..
Here's the SOAPserver code(WS.WEB_s.php):
require("WEB_s.php");
ini_set("soap.wsdl_cache_enabled", 0);
$server = new SoapServer('wsdl/WEB_s.wsdl');
$server->setClass("WEB_s");
$server->handle();
Where the main Class is(WEB_s.php):
final class WEB_s {
    public function getINFO(){
        $JsonOutput = '{"key":"value",...}';
        return $JsonOutput; 
    }
    public function setWAN($setCommand,$newConfigfilePath){
        $bOutput;
        return $bOutput;        
    } 
}
And Client side:
$(document).ready(function(){
    $('#qqq').button().click(function(){ 
        var soapMessage = LoginSoap($('#uid').val(),$('#pwd').val());
        alert('soapMessage');
        $.ajax({
            //url: 'libraries/WS.WEB_s.php/WEB_s/getINFO',//success , return null
            //url: 'libraries/WS.WEB_s.php/', //success , return null
            url: 'libraries/WS.WEB_s.php/getINFO',//success , return null
            type: 'GET', 
            timeout: (10* 1000),
            contentType: "text/xml",
            dataType: "xml",
            success: function( data,textStatus,jqXHR){
              alert('Server success(' + data+')('+ textStatus + ')(' + jqXHR + ')');
            },
            error: function (request, status, error) {
                alert('Server Error(' + status+')->'+error);
            },
            complete: function (jqXHR,  textStatus) {
                alert('Server success(' + jqXHR+')('+ textStatus + ')');
            }
        });                    
    });
});
The following is the corresponding WSDL file : http://codepaste.net/95wq9b
© Stack Overflow or respective owner