2013-02-13 82 views
0

这是我想要生成的xml,此刻 我希望每个标签和taginfo都被xml标签包围,每个标签都有一个xml标签,麻烦的是我是 从数据库中获取无数个列表,并且需要通过这个列表变成
肥皂客户端? 请你能帮助我的人了,感谢php soap客户端如何发送多维数组复杂类型?

这是我需要以下

<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文件

<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> 

回答

0

据我看到它从WSDL的AuthorisationList是一个序列AuthorisationData,它是一个包含Tag和TagInfo的数组本身,所以我认为您的数组结构必须如下所示:

$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'=> ? 
    ); 
} 
+0

谢谢,米歇尔你的概念看起来很合理,但php似乎并不喜欢它。在两种情况下都会收到错误“意外的T_DOUBLE_ARROW”,数据库循环也不会像=> – GAV 2013-02-13 15:04:29

+0

@ user2067893我在将数据行添加到数组时遇到了错误,但是在哪里得到双箭头?不能产生那个错误? – 2013-02-13 15:59:24

+0

双箭头,我是昏暗的。我发现你的数据库结果的想法完全适用于生成一个数组,我遇到的麻烦是如何将它放入肥皂请求中。 – GAV 2013-02-14 11:46:59