如何将 soap 请求中的结构数组作为参数传递?

How to pass array of structures in a soap request as an argument?

我正在尝试使用在 ColdFusion 中创建的 SOAP Web 服务。服务的 WSDL 请求部分如下所示:

<wsdl:message name="submitTicketWithExtraInfoRequest">
<wsdl:part name="sUserLdapAlias" type="xsd:string"></wsdl:part>
<wsdl:part name="sIssueDetails" type="xsd:string"></wsdl:part>
<wsdl:part name="sIssueSummary" type="xsd:string"></wsdl:part>
<wsdl:part name="sDeadlineReason" type="xsd:string"></wsdl:part>
<wsdl:part name="nRelatedTo" type="xsd:string"></wsdl:part>
<wsdl:part name="nPriorityLevel" type="xsd:string"></wsdl:part>
<wsdl:part name="nSegmentid" type="xsd:string"></wsdl:part>
<wsdl:part name="sSubmitterPhone" type="xsd:string"></wsdl:part>
<wsdl:part name="sCC" type="xsd:string"></wsdl:part>
<wsdl:part name="sCoSubmitter" type="xsd:string"></wsdl:part>
<wsdl:part name="sDeadline" type="xsd:string"></wsdl:part>
<wsdl:part name="arURLReference" type="impl:ArrayOf_tns1_URLReference"></wsdl:part>
</wsdl:message>

<complexType name="ArrayOf_tns1_URLReference">
    <complexContent>
         <restriction base="soapenc:Array">
             <attribute ref="soapenc:arrayType" wsdl:arrayType="tns1:URLReference[]"/>
         </restriction>
    </complexContent>
</complexType>

<complexType name="URLReference">
     <sequence>
         <element name="sURLReferenceComment" nillable="true" type="xsd:string"/>
         <element name="sURLReferenceURL" nillable="true" type="xsd:string"/>
     </sequence>
</complexType>

我正在使用 SoapUI 生成当前看起来像这样的请求:

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://some url/webService/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
   <soapenv:Header/>
   <soapenv:Body>
      <int:submitTicketWithExtraInfo soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <sUserLdapAlias xsi:type="xsd:string">?</sUserLdapAlias>
         <sIssueDetails xsi:type="xsd:string">?</sIssueDetails>
         <sIssueSummary xsi:type="xsd:string">?</sIssueSummary>
         <sTroubleshooting xsi:type="xsd:string">?</sTroubleshooting>
         <sDeadlineReason xsi:type="xsd:string">?</sDeadlineReason>
         <nRelatedTo xsi:type="xsd:double">?</nRelatedTo>
         <nPriorityLevel xsi:type="xsd:double">?</nPriorityLevel>
         <nSegmentid xsi:type="xsd:double">?</nSegmentid>
         <sSubmitterPhone xsi:type="xsd:string">?</sSubmitterPhone>
         <sCC xsi:type="xsd:string">?</sCC>
         <sCoSubmitter xsi:type="xsd:string">?</sCoSubmitter>
         <sDeadline xsi:type="xsd:string">?</sDeadline>
         <arURLReference xsi:type="int:ArrayOf_tns1_URLReference" soapenc:arrayType="dat:URLReference[]" xmlns:dat="http://dataservice"/>
      </int:submitTicketWithExtraInfo>
   </soapenv:Body>
</soapenv:Envelope>

对于其余参数,我只需将问号 ? 替换为实际值即可。问题是我不知道如何在我的 request.As 中传递 arURLReference 参数,从 WSDL 可以看出它是结构数组。

我使用 ColdFusion 的 getSOAPRequest() 函数来获取 Web 服务的请求 XML。看起来像这样:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <ns1:submitTicketWithExtraInfo soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://some url/webService/">
         <sUserLdapAlias xsi:type="xsd:string">psingh46</sUserLdapAlias>
         <sIssueDetails xsi:type="xsd:string">test ticket submit service with extra info</sIssueDetails>
         <sIssueSummary xsi:type="xsd:string">test ticket submit service with extra info</sIssueSummary>
         <sDeadlineReason xsi:type="xsd:string"/>
         <nRelatedTo xsi:type="xsd:string">45898</nRelatedTo>
         <nPriorityLevel xsi:type="xsd:string">71</nPriorityLevel>
         <nSegmentid xsi:type="xsd:string">18244</nSegmentid>
         <sSubmitterPhone xsi:type="xsd:string"/>
         <sCC xsi:type="xsd:string"/>
         <sCoSubmitter xsi:type="xsd:string"/>
         <sDeadline xsi:type="xsd:string"/>
         <arURLReference soapenc:arrayType="ns2:URLReference[2]" xsi:type="soapenc:Array" xmlns:ns2="http://dataservice" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
            <arURLReference xsi:type="ns2:URLReference">
               <sURLReferenceComment xsi:type="xsd:string">google link</sURLReferenceComment>
               <sURLReferenceURL xsi:type="xsd:string">http://google.com</sURLReferenceURL>
            </arURLReference>
            <arURLReference xsi:type="ns2:URLReference">
               <sURLReferenceComment xsi:type="xsd:string">so link</sURLReferenceComment>
               <sURLReferenceURL xsi:type="xsd:string">http://so.com</sURLReferenceURL>
            </arURLReference>
         </arURLReference>
      </ns1:submitTicketWithExtraInfo>
   </soapenv:Body>
</soapenv:Envelope>

使用上面的请求XML,使用SoapUI调用服务成功。 有关 getSOAPRequest() 函数的更多信息,请参阅此。 http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-6ca2.html