cfhttp和cfhttpparam在ColdFusion中

时间:2018-10-31 14:21:37

标签: coldfusion cfhttp cfhttpparam

我有一些XMl数据,我想使用XML数据发布到调度程序作业,因此使用cfhttp和cfhttpparam。但是由于运行此代码后的原因,我无法在我的一个站点中安排工作。尝试使用formfields,url和xml的所有选项均未成功。我使用cfsavecontent将所有数据保存到xml变量中,并使用该变量传递给cfhttparam值。不知道我在做什么错。这是下面的代码

<cfsavecontent variable="getAllValues">
    <start_job job="/cf/ecs/get_ecspseg1_data">
        <params>
        <param name="1_script" value="#script#" />
        <param name="2_login" value="#login#"/>
        <param name="3_customer" value="#customer#"/>
        <param name="4_account" value="#account#"/>
        <param name="5_begdate" value="#begdate#"/>
        <param name="6_enddate" value="#enddate#"/>
        </params>
    </start_job>
</cfsavecontent>

<cfhttp url="http://ecs" port="4444" username="test" authType = "BASIC" password="testing*1" method="post">
    <cfhttpparam type="xml" name="testing" value="#ToString(getAllValues)#"/>
</cfhttp>

这是更新的代码:

<cfsavecontent variable="getAllValues">
    <start_job job="/cf/smartecs/get_pseg1_data">
        <params>
        <param name="1_script" value="#script#" />
        <param name="2_login" value="#login#"/>
        <param name="3_customer" value="#customer#"/>
        <param name="4_account" value="#account#"/>
        <param name="5_begdate" value="#begdate#"/>
        <param name="6_enddate" value="#enddate#"/>
        </params>
    </start_job>
</cfsavecontent>

<cfhttp url="http://10.xxx.xxx.xxx" port="4444" username="myusername" authType = "BASIC" password="mypassword" method="post" >
    <cfhttpparam type="header" name="Content-Type" value="application/octet-stream">
    <cfhttpparam type="body" name="testing"  value="#getAllValues#"/>
</cfhttp>

1 个答案:

答案 0 :(得分:0)

当使用其他端口号时,我们甚至需要在URL的末尾保留一个/。当我在URL的末尾保留/时,它就像是一种魅力。 URL中的ColdFusion将不接受:。