[dba-Tech] Creating WebServices using PHP (preferred) or PERL

Shamil Salakhetdinov shamil-users at mns.ru
Fri Jan 9 12:34:29 CST 2004


Hi All,

Anybody knows it's a children work to make and install a Web Service
using MS Tools - e.g. using MS VB6 and MS SOAP Toolkit 3.0. It's the
same kind of easy work to get referenced and use a Web Service from
VS.Net...

Unfortunately I need/wanted to make a Web Services using PHP or PERL to
run it on my ISP site, which uses Linix and Apache.

I did some intensive search and I've found two interesting tools:

- PHP: ftp://ftp.activestate.com/WebService/PHP/webservice.zip
(http://dietrich.ganx4.com/nusoap/index.php)
- PERL:  http://soaplite.com/

PERL doesn't work on my ISP - some strange errors when using SOAP::Lite
package (Can't locate URI.pm in @INC ) and I didn't yet find how to
solve this problem - they say the path to one on the packages should be
explicitly specified - added to the @INC array - how to add the path to
this array - still a problem for me because I don't know PERL...

I went more smoothly with PHP (I did get working sample web service
callable from PHP itself) but I don't see how I can implement a PHP Web
Service callable from e.g. VS.Net. Did anybody here do that?

Basically, what is needed as far as I understand is to make a WSDL file
similar to the one generated by SOAP Toolkit with the only difference
that <port> element of this WSDL file should refer to a .php script -
something like that:

...
 <service name='wshello' >
  <port name='CHelloSoapPort' binding='wsdlns:CHelloSoapBinding' >
   <soap:address location='http://localhost/wstest/wshello.PHP'/>
  </port>
 </service>
...

Now, wshello.php should be able to accept SOAP requests from wshello web
service clients, parse them to get parameters, call a .PHP, .cgi, etc
.... implementations of a web service, get result and return SOAP
response to the client.

PHP solution (webservice.zip) referred above has sample code (see
P.S.) - the samples 1 and 2 work OK for me but I must say I don't know
what they mean by samples 3 and 4 nor I don't know how to call this
sample PHP web service (sample 1 - works OK when called from sample 2)
from VS.NET.

I guess the solution is very close if exists at all but I'm stuck with
what to do next :(

What I'm missing?
Can anybody help me?

TIA,
Shamil

P.S.

USAGE EXAMPLES: (webservice.zip)

1. BASIC SERVER EXAMPLE

<?php

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

?>

2. BASIC CLIENT USAGE EXAMPLE

<?php

require_once('nusoap.php');
$parameters = array('name'=>'dietrich');
$soapclient = new soapclient('http://someSOAPServer.com/hello.php');
echo $soapclient->call('hello',$parameters);

?>

3. WSDL CLIENT USAGE EXAMPLE

<?php

require_once('nusoap.php');
$parameters = array('dietrich');
$soapclient = new
soapclient('http://someSOAPServer.com/hello.wsdl','wsdl');
echo $soapclient->call('hello',$parameters);

?>

4. PROXY CLIENT USAGE EXAMPLE (only works w/ wsdl)

<?php

require_once('nusoap.php');
$soapclient = new
soapclient('http://someSOAPServer.com/hello.wsdl','wsdl');
$soap_proxy = $soapclient->getProxy();
echo $soap_proxy->hello('dietrich');

?>

--
e-mail: shamil at smsconsulting.spb.ru
Web:   http://smsconsulting.spb.ru/shamil_s



More information about the dba-Tech mailing list