Experience with SoapClient, and nested ArrayOf...
Posted: Mon Mar 22, 2010 7:23 pm
Folks,
Does anyone have experience using SoapClient to send nested arrays of data to a web service? I've been experiencing a problem that I can't seem to figure out. I've poured over PHP.net for info on Soap, researched WSDL to make sure my 3'rd party service provider's web-service is defined properly, and tried three different approaches to putting this outgoing soap call together but to no avail. What's happening is that the inner array of elements is getting populated with empty elements. Here's a snippet of wsdl:
I expect to send a SurveyResponseInsert element containing an array of QuestionContainer, each of which having an Answers element containing an array of AnswerContainer which contains an Answer element. Like so:
What I get is this when I ask my SoapClient for it's getLastRequest()
I've tried using nested arrays to set the data for the message, stdClasses and SoapVars but nothing seems to be working around this. Has anyone else experienced this problem, or something similar?
Does anyone have experience using SoapClient to send nested arrays of data to a web service? I've been experiencing a problem that I can't seem to figure out. I've poured over PHP.net for info on Soap, researched WSDL to make sure my 3'rd party service provider's web-service is defined properly, and tried three different approaches to putting this outgoing soap call together but to no avail. What's happening is that the inner array of elements is getting populated with empty elements. Here's a snippet of wsdl:
Code: Select all
<s:element name="SurveyResponseInsert">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SurveyId" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Questions" type="tns:ArrayOfQuestionContainer" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfQuestionContainer">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="QuestionContainer" type="tns:QuestionContainer" />
</s:sequence>
</s:complexType>
<s:complexType name="QuestionContainer">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="QuestionId" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Answers" type="tns:ArrayOfAnswerContainer" />
</s:sequence>
</s:complexType>
<s:complexType name="ArrayOfAnswerContainer">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="AnswerContainer" type="tns:AnswerContainer" />
</s:sequence>
</s:complexType>
<s:complexType name="AnswerContainer">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Answer" type="s:string" />
</s:sequence>
</s:complexType>
Code: Select all
<ns1:SurveyResponseInsert>
<ns1:SurveyId>2</ns1:SurveyId>
<ns1:Questions>
<ns1:QuestionContainer>
<ns1:QuestionId>14</ns1:QuestionId>
<ns1:Answers>
<ns1:AnswerContainer>
<ns1:Answer>answer1</ns1:Answer>
</ns1:AnswerContainer>
<ns1:AnswerContainer>
<ns1:Answer>answer2</ns1:Answer>
</ns1:AnswerContainer>
</ns1:Answers>
</ns1:QuestionContainer>
</ns1:Questions>
</ns1:SurveyResponseInsert>
Code: Select all
<ns1:SurveyResponseInsert>
<ns1:SurveyId>2</ns1:SurveyId>
<ns1:Questions>
<ns1:QuestionContainer>
<ns1:QuestionId>14</ns1:QuestionId>
<ns1:Answers>
<ns1:AnswerContainer/>
<ns1:AnswerContainer/>
</ns1:Answers>
</ns1:QuestionContainer>
</ns1:Questions>
</ns1:SurveyResponseInsert>