XML请求格式不正确或请求不完整 [英] XML request is not well-formed or request is incomplete

查看:180
本文介绍了XML请求格式不正确或请求不完整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在应用程序中使用虚拟商户支付网关:

We are using virtual merchant payment gateway in our application:

https://www.myvirtualmerchant.com/VirtualMerchant/download/developerGuide.pdf

我正在尝试记录CCSALE交易,但我不断收到此错误:

I am trying to record a CCSALE transaction but I keep getting this error:

<?xml version="1.0" encoding="UTF-8"?>
<txn><errorCode>6042</errorCode><errorName>Invalid Request Format</errorName><errorMessage>XML request is not well-formed or request is incomplete.</errorMessage></txn>

我在Fiddler POST中传递的请求中的XML是:

The XML I am passing in request in Fiddler POST is:

<txn>
<ssl_merchant_id>my_mer_id</ssl_merchant_id>
<ssl_user_id>my_usr_id</ssl_user_id>
<ssl_pin>my_pin</ssl_pin>
<ssl_test_mode>false</ssl_test_mode>
<ssl_transaction_type>ccsale</ssl_transaction_type>
<ssl_card_number>4111111111111111</ssl_card_number>
<ssl_exp_date>1215</ssl_exp_date>
<ssl_amount>1.00</ssl_amount>
</txn>

我只是删除了我的商家ID,用户ID和ssl密码.其余信息照原样.我将数据发布到: https://demo.myvirtualmerchant.com/VirtualMerchantDemo/processxml.do

I have simply removed my merchant id, user id and ssl pin. The rest of the information is just as it is. I am posting the data to: https://demo.myvirtualmerchant.com/VirtualMerchantDemo/processxml.do

任何人都可以让我知道为什么它表示XML格式不正确吗?

Can anybody let me know why does it say XML is not well formed?

推荐答案

首先,经过数小时的挫折,我发现PHP的处理方式非常缓慢.由于此XML错误非常持久,因此我想在Coldfusion中尝试此问题,并在2-3分钟内完成整个过程,没有XML错误,没有从API返回SSL废话.无论如何,放空就够了!这可能是防止XML格式正确的超级duper消息所需要的:

First of all, after hours of frustration I find PHP way of doing this very retarded. Since this XML error was so persistent, I wanted to try this in Coldfusion and in 2-3 minutes, the whole thing was done, no XML errors, no SSL crap returned from the API. Anyway, enough with the venting! This is probably what you need to prevent that XML well formedness super duper message :

curl_setopt($ch, CURLOPT_POSTFIELDS, array("xmldata=" . $fields_string));

假设您正在关注他们的文档,并且将变量保存在fields_string中,那么您所要做的就是键入模仿API变量的内容.在这种情况下,xmldata就可以.

Assuming you are following their documentation and you are holding the variables in fields_string all you need to do is type something that mimics a variable for the API. In this case, xmldata will do.

我还没有听引发这个问题的答案:卷曲错误:SSL读取:错误:00000000:lib(0):func(0):reason(0),errno 104

I have yet to listen to the answer which throws this : Curl error: SSL read: error:00000000:lib(0):func(0):reason(0), errno 104

这要归功于侦听错误,否则在摆脱XML错误之后,$ result将返回空.所以,就这样:

This is thanks to listening to the errors, otherwise $result returned empty after I got rid of XML error. So, here it goes :

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array("xmldata=" . $fields_string));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch);

if(curl_errno($ch))
    echo 'Curl error: ' . curl_error($ch);
else
    echo 'the return is ' . $result;

尚未设置SSL,那么为什么还要麻烦他们使用CURLOPT_SSL_VERIFYPEER和CURLOPT_SSL_VERIFYHOST?即使它是假的,它也不起作用,整个事情原来是查理·福克斯托(Charlie Foxtrot)!

SSL is not setup yet so why the heck they bothered with CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST? It's not working even when it's false, this whole thing turned out Charlie Foxtrot!

这篇关于XML请求格式不正确或请求不完整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆