Hi,
I'm writing a PHP web service and one function. I want to set up a web service in PHP. I need to generate the WSDL description for this web service so it's accessible from I.e. visual studio. It takes documents / search strings as inputs and recommends similar documents as output. I return an array with a first element resultCode (int) which shows if the operation was a success (1) or a failure (0). The second element, however, could either be an error message (string) which tells the user what went wrong, or a complex return type like an array with subelements for the different matching articles, i.e. array( array("heading"=>"article heading", "articleId"=>12345, "text"=>"body text of article"), array( ... ), ... ). I need to know how to generate/write the WSDL for that return type or how to do that in NuSOAP. How would you do that?
This is some of the code that I'm currently using to set up the service.
$server->wsdl->addComplexType(
'returnStructBase',
'complexType',
'struct',
'all',
'',
array('resultCode' => array('name'=>'resultCode', 'type'=>'xsd:int'),
'resultData' => array('name'=>'resultData', 'type'=>'xsd:anyType')
)
);
$server->wsdl->addComplexType(
'returnStructArray',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(
array('ref' => 'SOAP-ENC:arrayType',
'wsdl:arrayType' => 'tns:returnStructBase[]'
)
),
'tns:returnStructArray'
);
$server->register("GetRecommendations", array('username'=>'xsd:string', 'password'=>'xsd:string','articleId'=>'xsd:string',
'text'=>'xsd:string', 'returnText'=>'xsd:boolean'), array('return'=>'tns:returnStructArray'), $namespace, $namespace . '#getRecommendations', 'rpc', 'encoded', ' ... ');
Maybe PHP's loose typing made me use a bad design for a return type and I need to use something else?
Any recommendations welcome.