Original text: http://www.cnblogs.com/Jaypei/archive/2009/04/09/1432521.html
The last time I successfully used nuSOAP to transfer objects, there is often another requirement in the actual production process, which is Remotely returns an array of objects. It took me an afternoon to finally test it successfully, so I can’t wait to share it with everyone:)
Preparation
First define a class UserInfo:
class UserInfo {
var $UserName;
//... var $Sequence;
}
Then write a test Remote method:
function hello() {
A common nuSOAP program is as follows: (The whole process is a transformation of it)
$soap =newsoap_server();
$soap->wsdl->addComplexType(
) 'complexType',
'', array( )
'UserName'=>array
('name'=> ,
' type
'=>'
xsd:string'), '=>array( 'name'=>'Sequence', 'type' =>'xsd:int '
) ); ('hello', array(),array('return'=>'tns:UserInfo'));If you want to return a list, you need to change the type at return. Initially I found a list method that returns basic types such as string or int, as follows: $soap->register('hello', array(), array('return'=>'SOAP-ENC:Array') );
When this method is used on a custom composite type, the type will become: xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="object[2]"object is not What we want. So I searched for relevant information online and found the following method: $soap->register('hello', array(), array('return'=>'tns:UserInfoArray') );Here you need to customize Define and add an array type of tns:UserInfoArray, the method is as follows: $soap->wsdl->addComplexType( . 'UserInfoArray' ,
'
complexType'
,
,
'
SOAP-ENC:Array
'
,
array()
, array(The above introduces the object array passed by nusoap, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.