4

I am writing a SoapServer with PHP 5.2 to return a list of vacancies to another application. My WSDL doc requires a complex type along the lines of:

<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 is generating a large, nested array to assemble each vacancy and then returning the array of arrays (ie: vacancies) to the SoapServer.

Unfortunately, each array is indexed. So each VacancyType element within Vacancies has a unique index. This seems to throw the WSDL definition off and the data returned to me simply throws a parse error. I'd normally use associative arrays for key pair values, but as I'm dealing with n instances of VacancyType that wouldn't work as there wouldn't be a unique reference.

Is there a known workaround for this kind of scenario (eg: maybe an object), or should I rework my WSDL doc to cater for indexed arrays?

Thanks

4
  • Can you explain your data structure better? What's the relationship between Vacancy and Type? A vacancy can have multiple types? Maybe you could add a sample of your array to the question. Commented Dec 17, 2009 at 15:00
  • Sorry if this is a bit misleading, VacancyType refers to an XSD definition for a complex type (I don't think I need to detail it). For all intents and purposes it might as well be called Vacancy. The response for this function should return something like: * Vacancies * VacancyType * data within this... * VacancyType * data within this... * VacancyType * data within this... I build this with an array and let the SoapServer convert this into an appropriate response based on the WSDL, but it's struggling with an indexed array of VacancyType Commented Dec 21, 2009 at 10:22
  • Where is the problem occurring? Marshaling your array to a SOAPRequest? Wouldn't this just be a series of nested Vacancy objects? Commented Dec 21, 2009 at 19:37
  • It seems that PHP doesn't have support for things such as lists - which is really what I needed. This means I will probably need to amend my WSDL doc for the service to include some kind of index. Easy enough to ignore at the other end I guess Commented Dec 23, 2009 at 11:27

3 Answers 3

1

According to http://sam.xnet.tk/post/15/php-soap-server-part-2/ the rpc/literal style is working with xsd sequence. However, i cannot make it work with document/literal wrapped style, too.

Sign up to request clarification or add additional context in comments.

Comments

0

Did you gave nuSAOP a try? Requires no other installed PHP libs:

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

Comments

0

After all, I have found a solution: I construct XML by mysefl and use

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.