Friday, December 18, 2009

How to return multiple tag with Nusoap

How to create web service in php using the nusoap
With writting this blog please first read what is web service and how make with nusoap.
You can download and for tutorial for basic
I am here to write how to send the multiple tag in response

First we have create the complex data type that you want to send client but little different way.

$server->wsdl->addComplexType( 'business','complexType','array','all','',

This the code for adding complex data type.
  1. $server this the object of NuSOAP .
  2. business is name data type that you want to create.
  3. complexType the type of new data is complex
  4. array there two type of data one struct and another array.we will use array
  5. tagname this the name of tag that you can send inside the array.
Then you have create new datatype that contails the array of above data type.

$server->wsdl->addComplexType('array_business','complexType', 'array', '',
'SOAP-ENC:Array', //this tell the ENC is type of array
array('ref' => 'SOAP-ENC:arrayType', //now check in WSDL
'wsdl:arrayType' => 'tns:business[]')//the complex data array
'tns:business' //the name of complex data that

The above code explain that data array_business contains the array of business that given in "tns:"
Now just one thing to do is set the return type in function is "business".
Each array is an item tag,and each array element is child of item.

Have Dream Day.

No comments:

Post a Comment