调用SOAP Web服务功能

时间:2014-01-16 09:10:30

标签: web-services soap coldfusion

我正在尝试使用网络服务来保存数据。 Web服务URL类似于:

http://example.com/webservice1/order.asmx

当我想保存订单时,我会发送一个SOAP信封并且必须调用函数saveorder。如何在ColdFusion中指定我想调用此函数?

1 个答案:

答案 0 :(得分:1)

您必须使用cfhttp并构建SOAP信封并通过cfhttp请求传递它。

这是我前段时间写的:

<cfscript>
savecontent variable="local.sSoap" { 
    WriteOutput("
        <?xml version='1.0' encoding='utf-8'?>
            <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
                <soap:Body>
                    #arguments.sData#
                </soap:Body>
            </soap:Envelope>
        "); 
}
</cfscript>
<cfhttp url="https://apiconnector.com/API.asmx" method="post" result="httpResponse">
        <cfhttpparam type="header" name="SOAPAction" value="http://apiconnector.com/#arguments.sMethod#"/>
        <cfhttpparam type="header" name="accept-encoding" value="no-compression"/>
        <cfhttpparam type="xml" value="#trim( local.sSOAP )#"/>
</cfhttp>

你显然必须做出改变以满足自己的需要,但要点就在那里。

相关问题