为什么 SOAP 调用可以从 CFM 页面工作,而不能从 CFC 页面工作?

问题描述

我正在 Coldfusion 中处理 SOAP 请求。当我的代码从 .CFM 文件运行时,它可以工作。如果它是从 .CFC 文件运行的,则它不起作用。代码尽量相同(例如.CFC需要cfcomponent和cffunction标签)。

为什么它可以从一个而不是另一个工作?当我从 CFC 页面调用它时,我收到错误

Error message

有人知道为什么会发生这种情况吗?两个页面上的 SOAP 请求是相同的。带有 s3_client = boto3.client('s3') if not os.path.exists(os.path.dirname("some/relative/path/for/saving")): os.makedirs(os.path.dirname("some/relative/path/for/saving")) s3_client.download_file("s3.my.bucket","some/relative/path/ending/with/e365e14b-afd8-4e52-9457-cad42bb638f3.csv","not_hierarchical_path.csv") 以及所有 CFHTTP调用也相同。

这是 CFC 文件代码

CFHTTPParaM

CFM 版本的代码

<cfcomponent>
    <cffunction name="updateAgParcel" returntype="string" returnformat="plain" access="remote">
        <cfargument name="ag_pres_nr" required="true" type="string">
        <cfargument name="emp_nr" required="true" type="string">
        <cfargument name="dt_rcvd" required="true" type="string">
        <cfset dt_rcvd = DateFormat(#dt_rcvd#,"MMDDYYYY")>
        <cfsavecontent variable="soapBody">
            <cfoutput>
                <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ass="http://XXXXXX">
                   <soapenv:Header/>
                   <soapenv:Body>
                      <ass:LogAgPreserveFiling>
                            <ass:AG.PRES.NR>#ag_pres_nr#</ass:AG.PRES.NR>
                            <ass:TC>04</ass:TC>
                            <ass:EMP.NR>#emp_nr#</ass:EMP.NR>
                            <ass:LCAQ.DT.RCVD>#dt_rcvd#</ass:LCAQ.DT.RCVD>
                            </ass:LogAgPreserveFiling>
                    </soapenv:Body>
                </soapenv:Envelope>
            </cfoutput>
        </cfsavecontent>

        <cfhttp url="XXXXXXXXXXXXXXX" method="post" result="httpResponse">
            <cfhttpparam type="header" name="SOAPAction" value="XXXXXXXXXXXX" />
            <cfhttpparam type="header" name="Authorization" value="Basic XXXXXXXXXXXXXX" />
            <cfhttpparam type="header" name="accept-encoding" value="no-compression" />
            <cfhttpparam type="header" name="Content-Type" value="text/xml" />
            <cfhttpparam type="xml" value="#trim( soapBody )#" />
        </cfhttp>

        <cfif find( "200",httpResponse.statusCode )>
            <cfset soapResponse = xmlParse( httpResponse.fileContent ) />
            <cfset responseNodes = xmlSearch(soapResponse,"//*[ local-name() = 'VCfaultdetails'] ") />
            <cfif arrayLen(responseNodes) NEQ 0>
                <cfset error = #responseNodes[ 1 ].message.xmlText#>
                <cfreturn error>
            <cfelse>
                <cfreturn "">
            </cfif>
        </cfif>
    </cffunction>
</cfcomponent>

为了安全起见,我 XXXXXX 删除了一些 URL 等。另外,对于开发人员选择的命名空间(ass:)感到抱歉。它是 Assessor 的缩写。有人在开玩笑...

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)