wsdl-creator icon indicating copy to clipboard operation
wsdl-creator copied to clipboard

How to return array of objects with defined class

Open rolandothedev opened this issue 5 years ago • 0 comments

I have the following method signature I want to meet:

DetailedInfoResponse[] userInfo (String secretKey, DetailedInfoRequest[] requests)

Both DetailedInfoResponse and DetailedInfoRequest are objects that have their own properties. With the current syntax, how can I define the class?;

I've tried the following and it works but the type is generalized to "ns:ArrayOfRequests".

     * @WebMethod
     * @WebParam(param="object[] $requests { int $correlationNumber string $token }",header=false)
     * @WebParam(param="string $secretKey",header=false)
     * @WebResult(param="object[] $reponse{ int $correlationNumber string $userId }")

WSDL output:

<definitions name="RGS" targetNamespace="/"><types><xsd:schema targetNamespace="https://rgs.com"><xsd:complexType name="ArrayOfRequests"><xsd:complexContent><xsd:restriction base="soapenc:Array"><xsd:attribute ref="soapenc:arrayType" soap:arrayType="ns:Request[]"/></xsd:restriction></xsd:complexContent></xsd:complexType><xsd:element name="Request" nillable="true" type="ns:Request"/><xsd:complexType name="Request"><xsd:sequence><xsd:element name="correlationNumber" type="xsd:int"/><xsd:element name="token" type="xsd:string"/></xsd:sequence></xsd:complexType><xsd:complexType name="ArrayOfReponse"><xsd:complexContent><xsd:restriction base="soapenc:Array"><xsd:attribute ref="soapenc:arrayType" soap:arrayType="ns:Reponse[]"/></xsd:restriction></xsd:complexContent></xsd:complexType><xsd:element name="Reponse" nillable="true" type="ns:Reponse"/><xsd:complexType name="Reponse"><xsd:sequence><xsd:element name="correlationNumber" type="xsd:int"/><xsd:element name="userId" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:schema></types><message name="userInfoRequest"><part name="requests" type="ns:ArrayOfRequests"/><part name="secretKey" type="xsd:string"/></message><message name="userInfoResponse"><part name="reponse" type="ns:ArrayOfReponse"/></message><portType name="RGSPortType"><operation name="userInfo"><input message="tns:userInfoRequest"/><output message="tns:userInfoResponse"/></operation></portType><binding name="RGSBinding" type="tns:RGSPortType"><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><operation name="userInfo"><soap:operation soapAction="//#userInfo"/><input><soap:body use="literal" namespace="/"/></input><output><soap:body use="literal" namespace="/"/></output></operation></binding><service name="RGSService"><port name="RGSPort" binding="tns:RGSBinding"><soap:address location="/soap-server"/></port></service></definitions>

If I do the following then the definitions of UserInfoRequest and UserInfoResponse are excluded however the types are as I expect them.

     * @WebMethod
     * @WebParam(param="UserInfoRequest[] $requests { int $correlationNumber string $token }",header=false)
     * @WebParam(param="string $secretKey",header=false)
     * @WebResult(param="UserInfoResponse[] $reponse{ int $correlationNumber string $userId }")

WSDL output:

<definitions name="RGS" targetNamespace="/"><types><xsd:schema targetNamespace="https://rgs.com"><xsd:complexType name="ArrayOfRequests"><xsd:complexContent><xsd:restriction base="soapenc:Array"><xsd:attribute ref="soapenc:arrayType" soap:arrayType="xsd:UserInfoRequest[]"/></xsd:restriction></xsd:complexContent></xsd:complexType><xsd:complexType name="ArrayOfReponse"><xsd:complexContent><xsd:restriction base="soapenc:Array"><xsd:attribute ref="soapenc:arrayType" soap:arrayType="xsd:UserInfoResponse[]"/></xsd:restriction></xsd:complexContent></xsd:complexType></xsd:schema></types><message name="userInfoRequest"><part name="requests" type="ns:ArrayOfRequests"/><part name="secretKey" type="xsd:string"/></message><message name="userInfoResponse"><part name="reponse" type="ns:ArrayOfReponse"/></message><portType name="RGSPortType"><operation name="userInfo"><input message="tns:userInfoRequest"/><output message="tns:userInfoResponse"/></operation></portType><binding name="RGSBinding" type="tns:RGSPortType"><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><operation name="userInfo"><soap:operation soapAction="//#userInfo"/><input><soap:body use="literal" namespace="/"/></input><output><soap:body use="literal" namespace="/"/></output></operation></binding><service name="RGSService"><port name="RGSPort" binding="tns:RGSBinding"><soap:address location="/soap-server"/></port></service></definitions>

I tried looking in the documentation and unit test but could not find anything. Thanks in advance for your help!

rolandothedev avatar Dec 17 '18 03:12 rolandothedev