Structuring a PHP array for use in SOAP with WSDL

I am writing SoapServer with PHP 5.2 to return a job list to another application. My WSDL document requires a complex type in the following lines:

<xsd:element name="Vacancies"> <xsd:complexType> <xsd:sequence> <xsd:element name="Vacancy" type="ns:VacancyType" minOccurs="0" maxOccurs="unbounded"></xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> 

My function generates a large nested array to build each vacancy and then returns an array of arrays (i.e.: vacancies) in SoapServer.

Unfortunately, every array is indexed. Therefore, each VacancyType item in the Jobs section has a unique index. This seems to disable the WSDL definition, and the data returned to me simply causes a parsing error. I usually use associative arrays for key pair values, but since I am dealing with n VacancyType instances that will not work because there would be no unique reference.

Is there a known workaround for such a scenario (for example, perhaps an object), or should I rework my WSDL document to process indexed arrays?

thanks

+4
source share
3 answers

According to http://sam.xnet.tk/post/15/php-soap-server-part-2/, the rpc / literal style works with the xsd sequence. However, I cannot get it to work with a documented / literal wrapped style.

+1
source

Did you give nuSAOP a try? No other installed PHP libraries are required:

According to PHP documentation, PHP supports subsets of SOAP 1.1, SOAP 1.2, and WSDL 1.1.

0
source

In the end, I found a solution: I build XML on mysefl and use

 new SoapVar('<myitem>...</myitem><myitem>...</myitem>', XSD_ANYXML); 
0
source

All Articles