1

I created a simple web-service and i want JQuery to be able to use the webservice. The webservice has no XML output or JSON output so i have no clue how to set that up with JQuery. The webservice works fine with PHP though. I have tried to change the header of page to xml and JSON: ("Content-Type:text/xml"); and header('Content-type: application/json'); How do i set it up so JQuery can use the webservice?

Here is the full code:

SoapServer.php

header('Content-type: application/json');


function hello($name){
    return("hi" . $name);
}


$server = new SoapServer(null, array('uri'=>'http://localhost/PHPWebService/hello'));
$server->addFunction("hello");
$server->handle();


?>

SoapClient.php

<?php 
try{
    $client = new SoapClient(null, array(
            'location'=>"http://localhost/PHPWebService/SoapServer.php",
            'uri' => "http://localhost/PHPWebService/hello"

    ));

    $result = $client->hello("Bob");
    echo($result);


}catch(SoapFault $ex){
    $ex->getMessage();
}
?>

1 Answer 1

1

Since no one answered this question i have solved this a other way. I used jakesankey's RESTful service instead of SOAP and created a JSON webservice this way. It works nice and is exactly what i was looking for.

Here is the link to the PHP RestServer: https://github.com/jakesankey/PHP-RestServer-Class

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.