xml响应错误 [英] xml response error

查看:287
本文介绍了xml响应错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试发送xml消息并期待响应时,我会收到SSL连接超时错误:

I get SSL connection timeout error when I try sending xml message and expect a response:

$xml = <<<EOL
<?xml version='1.0' encoding='UTF-8'?> 
<abc>
<UserId>123</UserId> 
</abc>
EOL;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('xmlmessage' => $xml));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);

$result = curl_exec($ch);
if ($result === FALSE) {
    die(curl_error($ch));
}

echo $result

/ p>

Can anyone help?

推荐答案

上面的代码缺少:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 

创建一个名为test.php的文件,并在其中加入以下内容:

Other than that, you need to make sure curl has ssl support. Create a file named "test.php" and put the following in it:

<?php
phpinfo();
?>

,然后通过浏览器加载页面。在输出中,向下滚动到页面的中间,其中
可以看到有关安装/启用模块的详细信息。查找curl信息。如果它有SSL支持
,你会看到一些类似于(注意它如何提到ssl):

then load the page via your browser. On the output, scroll down towards the "middle" of the page where you can see details about the modules installed/enabled. Look for the curl information. If it has SSL support you will see something SIMILAR to (notice how it "mentions" ssl):

cURL Information    libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6

否则,您需要与服务器管理员联系,让他/她为其安装ssl支持。

Otherwise you'll need to contact the server admin to have him/her install ssl support for it.

这篇关于xml响应错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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