0

这是我想要生成的 xml,目前我希望每个标签和 taginfo 都被每个标签的 xml 标签包围,麻烦的是我从数据库中获取了一个列表,并且需要将此列表传递到
肥皂客户端?请问有人能帮帮我吗,谢谢

这就是我下面需要的

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

1 回答 1

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'=> ? 
    ); 
}
于 2013-02-13T11:23:05.867 回答