Web Services

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
fractalvibes
Forum Contributor
Posts: 335
Joined: Thu Sep 26, 2002 6:14 pm
Location: Waco, Texas

Web Services

Post by fractalvibes »

I downloaded NuSoap the other day and after some reading up, was able to easily write a php page that consumed a web service from Amazon.com for a client. We are making the transition to ASP.Net at work, so for practice I wrote my first "Hello World" Web Service using .Net the other day.

Now, with all that as a preface - can you use PHP as a web service provider also? Does NuSoap have that capability? I'll profess to not being real adept at XML and SOAP, so such classes as NuSoap are a big help!

thanks,

Phil J.
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

I'm not sure I completely understand your question, having seen way to many alternate definations of "Web Services", but I'll give it a go. I've never used NuSoap, so I don't know it can or can't do.

Yes, PHP can offer "web-services." I have code several scripts that are designed to produce XML datasets for automated consumption by other web-tools of the public data of my database.

PHP, by itself, isn't a "web service framework" so you won't have some of the "classic web serivice" tools built in -- such as service discovery. However I would be very surprised if there weren't at least several prototypes for PHP frameworks out there. PEAR might have something.
fractalvibes
Forum Contributor
Posts: 335
Joined: Thu Sep 26, 2002 6:14 pm
Location: Waco, Texas

Post by fractalvibes »

Ok - I found out that NuSoap can indeed be a Web Service provider. All I can find are very basic examples such as: How would one return a recordset worth of data?
=================
//BASIC SERVER EXAMPLE
require_once('nusoap.php');
$s = new soap_server;
$s->register('hello');
function hello($name){
// optionally catch an error and return a fault
if($name == ''){
return new soap_fault('Client','','Must supply a valid name.');
}
return "hello $name!";
}
$s->service($HTTP_RAW_POST_DATA);
=========================

Equally simple client
=====================
//BASIC CLIENT USAGE EXAMPLE
require_once('nusoap.php');
$parameters = array('name'=>'Phil');
$soapclient = new soapclient('http://yoursoapserverapp.php');
echo $soapclient->call('hello',$parameters);
=============================

Anyone know of any tutorials that go a little more in depth?

thanks,

Phil J.
User avatar
hhfbrouwer
Forum Newbie
Posts: 4
Joined: Wed Jun 25, 2003 4:50 am
Contact:

Yes it can

Post by hhfbrouwer »

Yeas you can use NuSoap in PHP.

Just look in the Amazon Webservices SDK in the folder PHPSample, there is an example there.

I use NuSoap with my website http://www.havestyle.tk
Post Reply