问题
This is the xml I want to produce, at the moment
I want each tag and taginfo to be surrounded by xml tags for each one, trouble is I'm
getting a list of however many from the database and need to pass this list into the
soap client?
Please you can someone help me out, thanks
this is what I need below
<ns1:sendListRequest><ns1:updateType>FULL</ns1:updateType>
<ns1:listVersion>1</ns1:listVersion><ns1:AuthorisationList>
<ns1:Tag>tag1</ns1:Tag><ns1:Taginfo>web example</ns1:Taginfo>
<ns1:Tag>tag2</ns1:Tag><ns1:Taginfo>web example2</ns1:Taginfo>
</ns1:AuthorisationList></ns1:sendListRequest></env:Body></env:Envelope>
this what I get <ns1:Tag>tag1tag2</ns1:Tag> which is probably expected from array I'm using
soap request
while ($row = $db->getResult()) {
$tags[] = $row['tags'];
}
$tags=implode($list);
$response = $client->SendList(array('updateType' =>
$updatetype,'listVersion' => $listversion,'AuthorisationList' =>
array('Tag' => $tags, 'Taginfo' => $taginfo));
WSDL file
<s:complexType name="SendListRequest">
<s:annotation>
<s:documentation>Defines the SendList.req PDU</s:documentation>
</s:annotation>
<s:sequence>
<s:element name="updateType" type="tns:UpdateType" minOccurs="1" maxOccurs="1" />
<s:element name="listVersion" type="s:int" minOccurs="1" maxOccurs="1" />
<s:element name="AuthorisationList" type="tns:AuthorisationData" minOccurs="0" maxoccurs="unbounded">
</s:sequence>
</s:complexType>
<s:element name="sendListRequest" type="tns:SendListRequest" />
<s:element name="sendListResponse" type="tns:SendListResponse" />
</s:schema>
</wsdl:types>
<wsdl:message name="SendListInput">
<wsdl:part name="parameters" element="tns:sendListRequest" />
</wsdl:message>
<wsdl:message name="SendListOutput">
<wsdl:part name="parameters" element="tns:sendListResponse" />
</wsdl:message>
<wsdl:portType name="Service">
<wsdl:operation name="SendList">
<wsdl:input message="tns:SendListInput" wsaw:Action="/SendList" />
<wsdl:output message="tns:SendListOutput" wsaw:Action="/SendListResponse" />
</wsdl:operation>
</wsdl:portType>
<s:complexType name="AuthorisationData">
<s:sequence>
<s:element name="Tag" type="tns:IdToken" minOccurs="1" maxOccurs="1"/>
<s:element name="TagInfo" type="tns:TagInfo" minOccurs="0" maxOccurs="1"/>
</s:sequence>
</s:complexType>
<s:simpleType name="UpdateType">
<s:restriction base="s:string">
<s:enumeration value="Different"/>
<s:enumeration value="Full"/>
</s:restriction>
</s:simpleType>
<wsdl:service name="Service">
<wsdl:documentation></wsdl:documentation>
<wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap">
<soap12:address location="http://Service/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
回答1:
As far as I see it from the WSDL the AuthorisationList is a sequence of AuthorisationData, which is an array itself containing Tag and TagInfo, so I think your array structure has to look like this:
$toSend = array(
'updateType' => $updatetype,
'listVersion' => $listversion,
'AuthorisationList' => array(
'AuthorisationData'=> array()
)
);
// and this could be a way to add your db results:
while ($row = $db->getResult()) {
// I can't see where you get the TagInfo from.
$toSend['AuthorisationData'][] = array(
'Tag'=>$row['tags'],
'TagInfo'=> ?
);
}
来源:https://stackoverflow.com/questions/14851933/php-soap-client-how-to-send-multi-dimentional-array-complex-type