SOAP方法调用,它将两个对象作为参数

时间:2012-06-01 21:25:17

标签: soap coldfusion wsdl

我正在进行SOAP调用以从下面的wsdl访问方法getMailingReports并且可以正常访问它。我的问题是当我必须使用createEmailMailing但必须传入两个对象的参数(Mailing和EmailContent)。这是来自stormpost(脉冲点),所以如果有人有这方面的经验,我会很感激。下面是我正在使用ColdFusion进行的wsdl和SOAP调用。同样,这个SOAP调用工作正常,但不知道如何模仿它并使用createEmailMailing方法。

http://api.stormpost.datranmedia.com/services/SoapRequestProcessor?wsdl

<cfsavecontent variable="soap">
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SOAP-ENV:Header>
                <ns0:username SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" xmlns:ns0="http://services.web.stormpost.skylist.com">fakelogin</ns0:username>
                <ns0:password SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" xmlns:ns0="http://services.web.stormpost.skylist.com">fakepassword</ns0:password>
            </SOAP-ENV:Header>
            <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s0="http://www.w3.org/2001/XMLSchema" xmlns:s1="http://schemas.xmlsoap.org/soap/encoding/">
                <ns0:getMailingReports xmlns:ns0="http://services.web.stormpost.skylist.com">
                    <from xsi:type="xsd:dateTime"><cfoutput>#dateFormat(arguments.from, "yyyy-mm-dd")#</cfoutput>T00:00:00.000</from>
                    <to xsi:type="xsd:dateTime"><cfoutput>#dateFormat(arguments.to, "yyyy-mm-dd")#</cfoutput>T23:00:00.000</to>
                    <type xsi:type="xsd:string">Mailings</type>
                    <channel xsi:type="xsd:string">EMAIL</channel>
                    <listid xsi:type="xsd:int">0</listid>
                    <limit xsi:type="xsd:int">#arguments.numRowsReturned#</limit>
                </ns0:getMailingReports>
            </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>
    </cfsavecontent>

    <cfhttp url="https://api.stormpost.datranmedia.com/services/SoapRequestProcessor" method="POST">
        <cfhttpparam type="header" name="Content-Type" value="text/xml">
        <cfhttpparam type="header" name="SOAPAction" value="">
        <cfhttpparam type="header" name="content-length" value="#len(trim(soap))#">
        <cfhttpparam type="header" name="charset" value="utf-8">
        <cfhttpparam type="XML" name="message" value="#trim(soap)#">
    </cfhttp>

1 个答案:

答案 0 :(得分:1)

我自己一直在学习SOAP和CF.我强烈建议SOAPUI进行测试。它解析了一个示例createEmailMailing请求没有问题。任何地方都有一个问号,你想把值写入数据库。

<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:ser="http://services.web.stormpost.skylist.com">
   <soapenv:Header>
      <authInfo xsi:type="soap:authentication" xmlns:soap="http://skylist.com/services/SoapRequestProcessor">
         <!--You may enter the following 2 items in any order-->
         <username xsi:type="xsd:string">?</username>
         <password xsi:type="xsd:string">?</password>
      </authInfo>
   </soapenv:Header>
   <soapenv:Body>
      <ser:createEmailMailing soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <mailing xsi:type="soap:Mailing" xmlns:soap="http://skylist.com/services/SoapRequestProcessor">
            <!--You may enter the following 37 items in any order-->
            <title xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</title>
            <externalID xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</externalID>
            <comment xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</comment>
            <protocol xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</protocol>
            <campaignID xsi:type="xsd:int">?</campaignID>
            <brandID xsi:type="xsd:int">?</brandID>
            <listID xsi:type="xsd:int">?</listID>
            <conditionOperator xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</conditionOperator>
            <condition1Column xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition1Column>
            <condition1Operator xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition1Operator>
            <condition1Value xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition1Value>
            <condition2Column xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition2Column>
            <condition2Operator xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition2Operator>
            <condition2Value xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition2Value>
            <condition3Column xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition3Column>
            <condition3Operator xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition3Operator>
            <condition3Value xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition3Value>
            <condition4Column xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition4Column>
            <condition4Operator xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition4Operator>
            <condition4Value xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition4Value>
            <condition5Column xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition5Column>
            <condition5Operator xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition5Operator>
            <condition5Value xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</condition5Value>
            <maxRecipients xsi:type="xsd:int">?</maxRecipients>
            <seeds xsi:type="soap:ArrayOf_soapenc_string"/>
            <blockDomains xsi:type="soap:ArrayOf_soapenc_string"/>
            <purgeLists xsi:type="soap:ArrayOf_xsd_int"/>
            <purgeSuppressionLists xsi:type="soap:ArrayOf_xsd_int"/>
            <queueTime xsi:type="xsd:dateTime">?</queueTime>
            <trackType xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</trackType>
            <openTrackType xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</openTrackType>
            <clickStreamType xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</clickStreamType>
            <advertiserName xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</advertiserName>
            <unsubReportsAddress xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</unsubReportsAddress>
            <unsubReportsSize xsi:type="xsd:int">?</unsubReportsSize>
            <priority xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</priority>
            <additionalLists xsi:type="soap:ArrayOf_xsd_int"/>
         </mailing>
         <content xsi:type="soap:EmailContent" xmlns:soap="http://skylist.com/services/SoapRequestProcessor">
            <!--You may enter the following 16 items in any order-->
            <subject xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</subject>
            <fromEmail xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</fromEmail>
            <fromName xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</fromName>
            <toEmail xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</toEmail>
            <toName xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</toName>
            <replyToEmail xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</replyToEmail>
            <replyToName xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</replyToName>
            <charset xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</charset>
            <encoding xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</encoding>
            <htmlContent xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</htmlContent>
            <textContent xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">?</textContent>
            <unsubContentID xsi:type="xsd:int">?</unsubContentID>
            <replyContentID xsi:type="xsd:int">?</replyContentID>
            <headerContentID xsi:type="xsd:int">?</headerContentID>
            <footerContentID xsi:type="xsd:int">?</footerContentID>
            <forwardToFriendContentID xsi:type="xsd:int">?</forwardToFriendContentID>
         </content>
      </ser:createEmailMailing>
   </soapenv:Body>
</soapenv:Envelope>

你也想改变你的一个参数:

<cfhttpparam type="header" name="SOAPAction" value="createEmailMailing">