我通常使用 CFHTTP 使用 SOAP Web 服务并将 XML 作为 HTTP 参数发布。但是,这一次我尝试使用 使用 webservice createObject
,但是当我将 XML 作为参数传递给 webservicews.someMethod(args);
时,它失败了。我尝试使用结构来保存参数值,但这也不起作用。因此,如何传递参数?部分 WSDL 如下
<xs:element name="ORDER">
<xs:complexType>
<xs:sequence>
<xs:element name="Header" type="schemaOne:HeaderType"/>
<xs:element maxOccurs="unbounded" name="Detail" type="schemaOne:DetailType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="DetailType">
<xs:sequence>
<xs:element ref="schemaOne:DTORDN"/>
<xs:element ref="schemaOne:DTRCID"/>
<xs:element ref="schemaOne:DTPRT"/>
<xs:element ref="schemaOne:DTQTY"/>
<xs:element ref="schemaOne:DTNTU"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="HeaderType">
<xs:sequence>
<xs:element ref="schemaOne:DSORDN"/>
<xs:element ref="schemaOne:DSRCID"/>
<xs:element ref="schemaOne:DSBFNM"/>
<xs:element ref="schemaOne:DSBLNM"/>
<xs:element minOccurs="0" ref="schemaOne:DSBENT"/>
<xs:element ref="schemaOne:DSBAD1"/>
<xs:element minOccurs="0" ref="schemaOne:DSBAD2"/>
<xs:element minOccurs="0" ref="schemaOne:DSBAD3"/>
<xs:element ref="schemaOne:DSBAD4"/>
<xs:element ref="schemaOne:DSBSTT"/>
<xs:element ref="schemaOne:DSBZIP"/>
<xs:element ref="schemaOne:DSBCNT"/>
</xs:sequence>
</xs:complexType>
这是我构建的结构。
<cfscript>
ORDER = {};
ORDER.Header = {};
ORDER.Detail = {};
ORDER.Header.DSORDN = '251716';
ORDER.Header.DSRCID = 'H';
ORDER.Header.DSBFNM = 'Joe';
ORDER.Header.DSBLNM = 'Smith';
ORDER.Header.DSBAD1 = '4997 County Road';
ORDER.Header.DSBAD4 = 'Springfield';
ORDER.Header.DSBSTT = 'MO';
ORDER.Header.DSBZIP = '49657';
ORDER.Header.DSBCNT = 'USA';
ORDER.Detail.DTORDN = '251716';
ORDER.Detail.DTRCID = 'D';
ORDER.Detail.DTPRT = '0300604';
ORDER.Detail.DTQTY = '0000000000001';
ORDER.Detail.DTNTU = '00000009.9900';
</cfscript>