web services in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
away_young
Forum Newbie
Posts: 3
Joined: Sat Mar 26, 2011 12:30 am

web services in php

Post by away_young »

Hi,

i want to start creating and accessing web services using php....i tried searching around the internet....but came up with lots of code which were too
difficult for me....can anyone please tell where can i find a simple tutorial to develop web services using php?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: web services in php

Post by califdon »

First of all, recognize that web services is not a simple operation, so you won't find a truly "simple" tutorial. But it's true that a lot of information on the web is more complicated than necessary for learning the fundamentals. This one is perhaps as simple as I can find quickly: http://www.ferdychristant.com/blog//art ... OMM-6J2QFF
away_young
Forum Newbie
Posts: 3
Joined: Sat Mar 26, 2011 12:30 am

Re: web services in php

Post by away_young »

Thank you califdon for the reply....i will go through the website....
away_young
Forum Newbie
Posts: 3
Joined: Sat Mar 26, 2011 12:30 am

Re: web services in php

Post by away_young »

hi,
i am able to get the web service to work without using WSDL....but when i try to use WSDL..i get a page telling me
'Connection to the server was reset while the page was loading'..i am putting my client as well as my server code here...can anyone tell me what the problem is?
client code

Code: Select all

<?php
require_once('lib/nusoap.php');
$client = new soapclient('http://localhost/WebServices_WSDL/server.php?wsdl', true);
$result = $client->call('hello', array('name' => 'bye'));
print_r($result);

?>
server code

Code: Select all

<?php
require_once('lib/nusoap.php');
$server = new soap_server();
$server->configureWSDL('server', 'urn:server');
$server->register('hello',                
    array('name' => 'xsd:string'),        
    array('return' => 'xsd:string'),     
    'urn:server',                      
    'urn:server#hello',                
    'rpc',                               
    'encoded',                            
    'Says hello '            
);
function hello($name) {
        return 'Hello, ' . $name;
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>

Post Reply