I have to create WSDL for my SoapServer which passes data from another service. The data which was provided to me has the following structure:
<operationName>
<parameterHeader></parameterHeader>
<parameterData1></parameterData1>
<parameterData2></parameterData2>
...
<parameterDataN></parameterDataN>
</operationName>
This means that I have to create the method
function operationName(parameterHeader, parameterData1, parameterData2, ... parameterDataN){
...
}
It is impossible to know how many parameters will be provided to my operation.
As a solution, I'm trying to create WSDL for the method without parameters, but inside this method use the function func_get_args()
to get all parameters.
Unfortunately, I still can't create proper WSDL and I'm not sure if this is possible.
Precise data (example) which should be received by my web service is the following:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<env:Header/>
<env:Body>
<tns:operationResponse xmlns:tns="http://somedomain.com/demo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://anotherdomain.com/anotherdemo">
<tns:ResponseHeader attrName1="data1" attrName2="data2" attrName3="data3" />
<tns:ObjectData>
<tns:ElementData ElementAttr1="data1" ElementAttr2="data2" ElementAttr3="data3"/>
</tns:ObjectData>
<tns:ObjectData>
<tns:ElementData ElementAttr1="data21" ElementAttr2="data22" ElementAttr3="data23"/>
</tns:ObjectData>
<tns:ObjectData>
<tns:ElementData ElementAttr1="data31" ElementAttr2="data32" ElementAttr3="data33"/>
</tns:ObjectData>
<tns:ObjectData>
<tns:ElementData ElementAttr1="data41" ElementAttr2="data42" ElementAttr3="data43"/>
</tns:ObjectData>
</tns:operationResponse>
</env:Body>
</env:Envelope>
Have you any experience with such kind of WSDL or maybe some ideas about how to get provided structure of the data?
I though about possibility to take into account as parameter name, so other data could be used as complexType. Maybe WSDL provides some tricks...
Like Mike, my first approach would be to use an array parameter. While it is possible to imagine unlimited parameters in a procedure, I'm pretty sure the kind of definition in WSDL is just enumerative, so you have to explicitly list your parameters. Consider also that some Web Service implementations might not be able to manage unlimited args (in this case, on the requestor side, so it is their problem and not yours).