Showing posts with label Example. Show all posts
Showing posts with label Example. Show all posts

WSDL Generation with and without $classmap option

Sunday, June 8, 2008

The $classmap is an option you can provide to the WSService constructor to tells the WSF/PHP engine that how you map the xml elements to PHP classes in your program.

When you provide classmap option, your service function declration should be such that it input the request object and output the response object.

When you don't provide classmap option, you will have a service function declration with set of input fields as input parameters. (Note that in both cases the response can be either an array or response, only the request parameter set is different from each other in two cases)

You can see how the WSDL is genererting for both above cases, which will also demonstrate the different between the service fuction declarations.

1. When the $classmap is provided, http://labs.wso2.org/wsf/php/php2wsdltool.php?example=Example3
The function declration is

/**
* echoValue function
* @param object Foo $echoString echoString description
* @return object FooResponse $echoStringResponse
*/
function echoValue($echoString){
}

2. When the $classmap is not provided, http://labs.wso2.org/wsf/php/php2wsdltool.php?example=Example4
The function declration is
/**
* echoValue function
* @param array of object Foo $param1 param1 description
* @param string $param2
* @return array of object Boo $ret_value
*/
function echoValue($param1, $param2){
}

You can find more details at here, http://wso2.org/project/wsf/php/1.3.2/docs/wsdl_generation_api.html

Hello World Service with PHP SOAP Extension, NuSOAP and WSF/PHP

Monday, January 28, 2008

With SOAP extension:
<?php

function
hello($param) {
$retval = 'Hello, '.$param;
return $retval;
}

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

With NuSOAP:
<?php
require_once('../lib/nusoap.php');

$server
= new soap_server;
$server->register('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);
?>

With WSF/PHP:
<?php   

function
hello($message) {

$simplexml = new SimpleXMLElement($message->str);
$name = $simplexml->name[0];

$responsePayloadString = <<<XML
<helloResponse>
<return>Hello, $name</return>
</helloResponse>

XML;

return
$responsePayloadString;
}

$service
= new WSService(array("operations" => array("hello")));
$service->reply();
?>