以下代码在CF10上运行正常。
httpSvc = New http();
httpSvc.setMethod("post");
httpSvc.setCharset("utf-8");
httpSvc.setUrl(svcLocation);
httpSvc.setClientCert(certLocation);
httpSvc.setClientCertPassword(certPassword);
httpSvc.addParam(type="body", name="body",value=requestParameters);
result = httpSvc.send().getPrefix();
requestParameters的值为:
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:processCreditCard xmlns:ns2="urn:com.qvalent.payway.api">
<requestParameters>customer.orderNumber=5396&card.CVN=070&order.amount=101&customer.merchant=xxxx&card.expiryMonth=08&card.expiryYear=20&order.ECI=SSL&card.PAN=0000000000000008&card.currency=AUD&customer.username=xxxxxx&order.type=capture&customer.password=xxxxxxx</requestParameters>
</ns2:processCreditCard>
</S:Body>
</S:Envelope>
但是,当我将它放在CF9服务器上时,响应FileContent为空,我得到以下状态代码:
415 Unsupported Media Type
以下是显示完整回复的链接:http://www.onoffezy.com/_testing/gateway/
拖网Google,415状态代码表明客户端请求的mime类型在服务器上不可用。但是我找不到可以为请求设置mime类型的任何地方。在cf9和cf10之间默认的mimetype是否存在差异?
我仔细查看了两个版本的文档,但找不到可以解释这一点的差异。
如果有人能够对此有所了解并让我知道我需要在CF9上采取不同的做法,我们将非常感激。
非常感谢
答案 0 :(得分:1)
感谢所有帮助。我发现了问题。
httpSvc.addParam(type="body", name="body",value=requestParameters);
需要更改为:
httpSvc.addParam(type="xml", name="body",value=requestParameters);
看来cf9通过二进制发送type ='body',但是cf10将它作为一个字符串发送,或者计算出它是xml并按原样处理它。一旦我将类型更改为'xml',cf9就开始将其作为xml字符串发送,而不是二进制。
答案 1 :(得分:0)
虽然我无法确定这会解决您的问题,但您是否尝试将“接受”请求标头设置为响应的内容类型?
例如:
acceptType = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
httpSvc.addParam(name="Accept", value=acceptType, type="header");
答案 2 :(得分:0)
根据documentation here type="body"
指定HTTP请求的正文。 ColdFusion不会自动设置内容类型标头或URL对主体内容进行编码。要指定内容类型,请使用带有type = header的单独cfhttpparam标记。因此,可能有助于为您的请求指定此标头。
类似的东西:
httpSvc.addParam(type="header", name="Content-Type", value="application/x-www-form-urlencoded");
您没有提供身体内容的示例。您可能必须使用特定内容类型的值。 Here is a list of the available MIME types。
您在示例中的变量requestParamaters
中拼错了单词参数。它的价值是什么?