您可以在 Coldfusion 中编写 Web 服务调用而不使用 createObject(“webservice”....即使用 Java

发布于 01-07 06:45 字数 565 浏览 4 评论 0原文

我在 Adob​​e 网站上找到了此信息: 使用 ColdFusion 不生成的 Web 服务。但是,我在使用此 Web 服务进行身份验证时仍然遇到问题: https://secure .eloqua.com/API/1.2/Service.svc?wsdl

身份验证确实有效,因为我已设法通过 .Net 访问这些方法。这可能是 CF 无法处理的 Web 服务吗?

Eloqua 站点有 Java 代码示例,但它假定使用 Netbeans 的 Java 开发环境。您可以绕过内置的 CF Web 服务调用并直接在 Java 中执行吗?

I found this information on the Adobe website: Consuming web services that ColdFusion does not generate. However, I am still having problems authenticating with this web service: https://secure.eloqua.com/API/1.2/Service.svc?wsdl

The authentication does work, as I have managed to access the methods via .Net. Is it possible this is a web service that CF can't process?

The Eloqua site has code samples for Java, but it assumes a Java Dev Environment using Netbeans. Can you bypass the built in CF web service calls and do it directly in Java?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梅倚清风2025-01-14 06:45:11

Eloqua 使用 WS-Security 来处理 ColdFusion 不支持的 SOAP 消息(需要 Axis2)。

但是您可以使用 Anthony Israel-Davis 的 cfWSAuthenticator(ColdFusion CFC)将 WS-Security 添加到 SOAP 请求 -> 希望它

会有所帮助。

Eloqua is using WS-Security for SOAP messages which ColdFusion does not support (need Axis2).

BUT you can use Anthony Israel-Davis's cfWSAuthenticator, A ColdFusion CFC to add WS-Security to SOAP request -> https://github.com/anthony-id/cfWSAuthenticator

Hope it will help.

豆芽2025-01-14 06:45:11

这个问题有点晚了,但我能够通过在 ColdFusion 中手动构建请求正文和标头,向 ws security SOAP 服务发出有效请求,无需任何外部 jar,也无需直接调用任何 java 库。 规范 对于 WSS(Web 服务安全)用户名令牌非常简单。您可以执行如下操作来生成安全标头,并将其添加到自定义构建的 SOAP 负载中。关键是为每个请求生成一个合规且唯一的随机数以及合规的创建日期/时间。

如果您需要有关构建和发送请求的更多信息,请查看 使用 ColdFusion 和 CFHTTP 发出 Soap Web 服务请求。一旦您使用各种实用方法(发送请求、创建安全标头等)构建了 cfc,就需要创建与您要调用的 API 方法相对应的特定函数(在soapUI 中加载 wsdl、复制/粘贴将请求正文放入您的 cfc 函数中,根据需要添加参数和业务逻辑,解析响应)。

<cffunction name="generateSecurityHeader" access="private" returntype="string" output="false">
        <cfset var loc = structNew() />
        <cfsavecontent variable="loc.soapSecurityHeader">
            <cfoutput>
                <soapenv:Header>
                    <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                        <wsse:UsernameToken wsu:Id="UsernameToken-1">
                            <wsse:Username>USERNAME</wsse:Username>
                            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0##PasswordText">PASSWORD</wsse:Password>
                            <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0##Base64Binary">#ToBase64(createUUID())#</wsse:Nonce>
                            <wsu:Created>#Dateformat(Now(),'yyyy-mm-ddThh:mm:ss')#Z</wsu:Created>
                        </wsse:UsernameToken>
                    </wsse:Security>
                </soapenv:Header>
            </cfoutput>
        </cfsavecontent>
        <cfreturn loc.soapSecurityHeader>
    </cffunction>

A bit late to this question, but I was able to make valid requests to a ws security SOAP service by building the request body and headers manually in ColdFusion without any external jars and without calling any java libraries directly. The spec for WSS (Web Services Security) username token is quite simple. You can do something like the below to generate the security header and just add it to your custom built SOAP payload. The key is generating a compliant and unique nonce with every request along with a compliant created date/time.

If you need more info on building and sending the requests in general, take a look at Making Soap Web Service Request with ColdFusion and CFHTTP. Once you have built a cfc with various utility methods in place (send request, create security header, etc), it is a matter of creating specific functions corresponding to the API methods you want to call (load the wsdl in soapUI, copy/paste the request body into your cfc function, add arguments and business logic as needed, parse the response).

<cffunction name="generateSecurityHeader" access="private" returntype="string" output="false">
        <cfset var loc = structNew() />
        <cfsavecontent variable="loc.soapSecurityHeader">
            <cfoutput>
                <soapenv:Header>
                    <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                        <wsse:UsernameToken wsu:Id="UsernameToken-1">
                            <wsse:Username>USERNAME</wsse:Username>
                            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0##PasswordText">PASSWORD</wsse:Password>
                            <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0##Base64Binary">#ToBase64(createUUID())#</wsse:Nonce>
                            <wsu:Created>#Dateformat(Now(),'yyyy-mm-ddThh:mm:ss')#Z</wsu:Created>
                        </wsse:UsernameToken>
                    </wsse:Security>
                </soapenv:Header>
            </cfoutput>
        </cfsavecontent>
        <cfreturn loc.soapSecurityHeader>
    </cffunction>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文