【问题标题】:Coldfusion - HTTPS error / X.509 ws-securityColdfusion - HTTPS 错误/X.509 ws-security
【发布时间】:2016-05-27 09:24:31
【问题描述】:

我对 SOAP 很陌生,这是我的第一个项目。我正在尝试连接到 HTTPS WSDL,以便在我的网页上提取一些信息。

已为本地服务器与服务提供商服务器连接准备好证书设置。当我尝试连接 https 网络服务时有响应,所以我相信两台服务器之间没有连接问题:

这是第三方技术团队提供的 SOAPUI 示例:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
     xmlns:soap="http://soap.ipr.tfp.com/">
    <soapenv:Header/>
    <soapenv:Body>
       <soap:create>
          <arg0>
            <attribute_1>abc</attribute_1>
            <attribute_2></attribute_2>
            <attribute_3>abc123</attribute_3>
            <attribute_4>abc234</attribute_4>
            <attribute_5></attribute_5>
          </arg0>
       </soap:create>
    </soapenv:Body>
</soapenv:Envelope>

以下是我用于连接 Web 服务的 cfm 代码:​​

<cfscript>
    ws = CreateObject("webservice", [HTTPS URL]?wsdl);
    //show web service methods for debugging purposes
    writeDump(ws);

    // construct arguments
    args = {attribute_1="abc"
            , attribute_2=""
            , attribute_3="abc123"
            , attribute_4="abc234"
            , attribute_5=""
        };
    // call the method
    result  = ws.create(arg0=args);

    writeDump(result)
</cfscript>

问题:

执行 cfm 脚本时收到以下错误消息:

     Cannot perform web service invocation create.
The fault returned when invoking the web service operation is:
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
 faultSubcode: 
 faultString: These policy alternatives can not be satisfied: 
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}AsymmetricBinding: Received Timestamp does not match the requirements
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}X509Token: The received token does not match the token inclusion requirement
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}X509Token
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}InitiatorToken
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}RecipientToken
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}IncludeTimestamp: Received Timestamp does not match the requirements
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SignedParts: {http://schemas.xmlsoap.org/soap/envelope/}Body not SIGNED
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EncryptedParts: {http://schemas.xmlsoap.org/soap/envelope/}Body not ENCRY... 

问题:

  1. 此错误是否与 ColdFusion 密钥库中的 SSL 证书设置有关?

  2. 我的 CFM 脚本有什么问题吗?参考SOAPUI示例,xml格式为`[arg0] --> [attribute_1]、[attribute_2]等。我可以这样传递属性吗?

    • 结果 = ws.create(arg0=args);
  3. SoapUI 工具提供相同的服务。我这里有什么遗漏吗?

感谢您的宝贵时间。感谢您的帮助。

2016-05-30 - 更新 -

我尝试使用CFHTTP 标记提交 XML,但它似乎返回了一个不同的错误:

<cfhttp
    url     = "[HTTPS URL]?wsdl"
    method  ="post"
    result  ="httpResponse" 
    charset ="utf-8">

    <cfhttpparam
        type="header"
        name="accept-encoding"
        value="no-compression"
    />
    <cfhttpparam
        type="xml"
        value="#trim( soapBody )#"
        />
</cfhttp>

错误:

这是文件内容中的错误信息:

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <soap:Fault>
            <faultcode>soap:Server</faultcode>
            <faultstring>These policy alternatives can not be satisfied: 
            {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}
            AsymmetricBinding: Received Timestamp does not match the requirements 
            {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}
            X509Token: The received token does not match the token inclusion requirement 
            {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}
            X509Token 
            {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}
            InitiatorToken 
            {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}
            RecipientToken 
            {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}
            IncludeTimestamp: Received Timestamp does not match the requirements 
            {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}
            SignedParts: {http://schemas.xmlsoap.org/soap/envelope/}
            Body not SIGNED 
            {http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}
            EncryptedParts: 
            {http://schemas.xmlsoap.org/soap/envelope/}
            Body not ENCRYPTED
            </faultstring>
        </soap:Fault>
    </soap:Body>
</soap:Envelope> 

错误消息似乎类似于cfobject 标记。当我仔细阅读错误消息时,它似乎与 X.509 ws-security 加密有关,其中 SOAP 内容需要在发送到 Web 服务请求之前进行加密。

经过一些研究,加密流程似乎如下:

  1. 将 SOAP 内容保存到临时文件夹中。

  2. 使用 Java Class 文件将 SOAP 内容加密为 X.509 ws-security 格式。

  3. 向 Webservice 发送新的加密 SOAP 内容。

我不知道 CF 如何处理 Java 类文件。有没有人做过同样的加密转换?

【问题讨论】:

  • 您运行的是什么版本的 ColdFusion? Axis 1 还是 Axis 2 的 Web 服务设置?
  • 嗨 Sean Coyne,我们正在使用 Coldfusion 9。我不确定我们的网络团队所做的 Web 服务设置。这2有什么区别吗?这是导致此错误的可能原因吗?

标签: web-services ssl soap https coldfusion


【解决方案1】:

在你的代码中连接到网络服务,改变

ws = CreateObject("webservice", [HTTPS URL]);

ws = CreateObject(
  "webservice", 
  "[HTTPS URL]",
  {wsversion="1"}
);

如果只有轴 1 适合您。

还要检查另一端,如果您使用 ColdFusion 公开 Web 服务,请确保已为 Axis 1 设置。

【讨论】:

  • 他们使用的是 CF9,默认为 Axis1。 wsversion 仅在 CF10+ 中受支持。
  • 那么它可能在另一端。让我们看看他是否可以改变暴露的Web服务端。
  • 嗨,Alex Baban,感谢您的信息。明天将与网络服务供应商核实。
  • 嗨,Alex Baban,我尝试添加您的代码建议,但似乎没有运气。我认为这与 X.509 WS-security 相关,其中 SOAP 内容需要在发送到 Web 服务之前进行加密,
  • 我了解您将 ColdFusion 9 作为客户端,因此您不需要 {wsversion="1"},因为 ColdFusion 9 仅支持 Axis1。但是您在暴露 Web 服务的服务器端有什么。那也是一个 ColdFusion 服务器还是别的什么?也许您可以将其配置为以某种方式使用 Axis1。
猜你喜欢
  • 2013-05-03
  • 1970-01-01
  • 2011-09-19
  • 2013-01-31
  • 1970-01-01
  • 1970-01-01
  • 2014-08-16
  • 2014-11-16
  • 1970-01-01
相关资源
最近更新 更多