|
| Help with complexType in Doc/Lit Server | |
Joined: 15 Jul 2008 |
Posts: 1 |
|
|
|
Posted: Mon Jul 14, 2008 6:53 am |
|
|
|
|
|
Hi,
I am trying to create a NuSOAP doc/lit server, but having problem with complex types.
My code is
<?php
require_once('..\lib\nusoap.php');
$server = new soap_server();
$server->configureWSDL('ABCSearchService', 'http://new.webservice.namespace','','document');
$server->wsdl->schemaTargetNamespace = 'http://new.webservice.namespace';
$server->wsdl->addComplexType(
'GetABCRequestType',
'complexType',
'struct',
'sequence',
'',
array(
'firstname' => array('name' => 'firstname', 'type' => 'xsd:string'),
'surname' => array('name' => 'surname', 'type' => 'xsd:string')
)
);
$server->wsdl->addComplexType(
'GetABCResponseType',
'complexType',
'struct',
'sequence',
'',
array(
'name' => array('name' => 'name', 'type' => 'xsd:string')
)
);
$server->register(
'GetABC',
array('GetABC' => 'tns:GetABCRequestType'),
array('GetABCResponse' => 'tns:GetABCResponseType'),
'http://new.webservice.namespace',
'ABCSearch',
'document',
'literal',
''
);
function GetABC($inputs)
{
//return $GetABC[0] . ' ' . $GetABC[1];
return 'ABC' . ' ' . 'XYZ';
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
|
and the generated WSDL is
<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://new.webservice.namespace" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://new.webservice.namespace">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://new.webservice.namespace">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
<xsd:complexType name="GetABCRequestType">
<xsd:sequence>
<xsd:element name="GetABC" type="tns:GetABCRequestType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="GetABCResponseType">
<xsd:sequence>
<xsd:element name="GetABCResponse" type="tns:GetABCResponseType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="GetABC" type="tns:GetABCRequestType"/>
<xsd:element name="GetABCResponse" type="tns:GetABCResponseType"/>
</xsd:schema>
</types>
<message name="GetABCRequest">
<part name="parameters" element="tns:GetABC"/>
</message>
<message name="GetABCResponse">
<part name="parameters" element="tns:GetABCResponse"/>
</message>
<portType name="ABCSearchServicePortType">
<operation name="GetABC">
<input message="tns:GetABCRequest"/>
<output message="tns:GetABCResponse"/>
</operation>
</portType>
<binding name="ABCSearchServiceBinding" type="tns:ABCSearchServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetABC">
<soap:operation soapAction="ABCSearch" style="document"/>
<input>
<soap:body use="literal" namespace="http://new.webservice.namespace"/>
</input>
<output>
<soap:body use="literal" namespace="http://new.webservice.namespace"/>
</output>
</operation>
</binding>
<service name="ABCSearchService">
<port name="ABCSearchServicePort" binding="tns:ABCSearchServiceBinding">
<soap:address location="http://127.0.0.1/testserverABC2.php"/>
</port>
</service>
</definitions>
|
I would like to see
<xsd:complexType name="GetABCRequestType">
<xsd:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="surname" type="xs:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="GetABCResponseType">
<xsd:sequence>
<xs:element name="name" type="xs:string"/>
</xsd:sequence>
</xsd:complexType>
|
instead of
<xsd:complexType name="GetABCRequestType">
<xsd:sequence>
<xsd:element name="GetABC" type="tns:GetABCRequestType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="GetABCResponseType">
<xsd:sequence>
<xsd:element name="GetABCResponse" type="tns:GetABCResponseType"/>
</xsd:sequence>
</xsd:complexType>
|
Any suggestions will be helpful.
Thanks.
|
|
|
| [solved] | |
Joined: 31 May 2010 |
Posts: 1 |
|
|
|
Posted: Mon May 31, 2010 10:12 am |
|
|
|
|
|
I'm solved problem of array of structure:
$server->wsdl->addComplexType(
'clsDispIds',
'complexType',
'struct',
'sequence',
'',
array(
'id_disp' => array('name' => 'id_disp', 'type' => 'xsd:int'),
'id_loc' => array('name' => 'id_loc', 'type' => 'xsd:string')
)
);
// array di clsDispIds
$server->wsdl->addComplexType(
'arrclsDispIds',
'complexType',
'array',
'sequence',
'',
array(
'item' => array('name' => 'item', 'type'=>'tns:clsDispIds','minOccurs' => '0', 'maxOccurs' => 'unbounded')
)
);
$server->register(
'GetIdDispCollection', // nome operazione
array('id'=>'xsd:int'), // input
array('return'=>'tns:arrclsDispIds'), // output
NAMESPACE,
true,
'document',
'literal',
'restituisce tutti i dispositivi per il canale specificato',
'http://schemas.xmlsoap.org/soap/encoding/'
);
nuSoap have a bug on the response creation and add automatically the tag "item" for each array element, therefore complexType have mandatory name "item"
This is my response that's correct deserialized by php, java & .net
stdClass Object (
[return] => stdClass Object (
[item] => Array ( [0] => stdClass Object ( [id_disp] => 11718 [id_loc] => '')
[1] => stdClass Object ( [id_disp] => 11722 [id_loc] => '')
[2] => stdClass Object ( [id_disp] => 11723 [id_loc] => '')
[3] => stdClass Object ( [id_disp] => 11724 [id_loc] => '')
) ) )
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT - 5 Hours
Page 1 of 1
|
|
|
| |