在CURL Soap PHP中没有得到正确的响应

德赛

$ length = strlen($ requestXml); $ ch = curl_init($ serviceUrl);

curl_setopt($ch, CURLOPT_VERBOSE, true);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: text/xml; charset=utf-8',
    "SOAPAction: \"https://example.com/PMAPI/example/$action\"",
    "Content-length: ".strlen($requestXml)
));

curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);

curl_setopt($ch, CURLOPT_COOKIEFILE, "cookieFIle.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookieFIle.txt");
curl_setopt($ch, CURLOPT_HEADER, 0);

$output = curl_exec($ch);
$info = curl_getinfo($ch);


curl_close($ch);

$xml=  simplexml_load_string($output);
print_r($xml);

我得到的输出:

127464347

不是xml格式。但是在View Source中,代码为XML格式。但是,当我将此输出字符串解析为xml解析器时,它没有用。

输出应采用以下格式,我可以在视图源页面中看到该格式。

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><TopUpRequestResponse xmlns="https://dollarphone.com/PMAPI/PinManager"><TopUpRequestResult><responseCode>1</responseCode><TransId>27464347</TransId></TopUpRequestResult></TopUpRequestResponse></soap:Body></soap:Envelope>

当我尝试访问该对象时。错误是“试图获取非对象的属性”。

请有人帮我解决这个问题吗?

德赛

我找到了解决方案:我只是从结果中删除了标签。并且有效。

  $response1 = str_replace("<soap:Body>","",$output);
        $response2 = str_replace("</soap:Body>","",$response1);

        // converting to XML
        $parser = simplexml_load_string($response2);

谢谢

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

没有得到预期的 PHP cURL 响应

来自分类Dev

PHP curl Soap请求错误

来自分类Dev

使用 Curl PHP 的 Soap 请求

来自分类Dev

在PHP中从cURL Soap迁移到Soap Client

来自分类Dev

Curl得到POST响应,但是node.js没有得到POST响应

来自分类Dev

Curl正在获得POST响应,但是node.js没有得到POST响应

来自分类Dev

使用CURL的SOAP API

来自分类Dev

如何使用php curl发送XML soap请求

来自分类Dev

PHP7 cURL 和 SOAP 请求 SSL 失败

来自分类Dev

对 SOAP Web 服务的 PHP Curl 请求的错误请求

来自分类Dev

带有 .p12 SSL 证书的 curl/soap 请求

来自分类Dev

使用 cURL 的 Sabre SOAP API

来自分类Dev

PHP,CURL得到正文响应

来自分类Dev

没有Soap Client的PHP Soap Server

来自分类Dev

PHP curl没有发布正确的字段

来自分类Dev

PHP SOAP 响应

来自分类Dev

json_decode没有通过curl调用返回正确的api响应的php数组

来自分类Dev

Rxjava,Retrofit响应主体没有得到正确的答案?

来自分类Dev

PHP Soap 没有创建正确的 xml 文档

来自分类Dev

curl`effective_url`没有得到最后一个有效的URL

来自分类Dev

使用SOAP和curl将列添加到表中。如何将访问令牌添加到xml?

来自分类Dev

PHP中的Soap Client

来自分类Dev

从 PHP 中的 SOAP 响应中提取数据

来自分类Dev

在 swift HTTP 请求中没有得到完整的响应?

来自分类Dev

PHP-对JSON的SOAP响应

来自分类Dev

如何将SOAP请求curl转换为RCurl

来自分类Dev

如何使用curl和SOAP调用MobileFirst适配器?

来自分类Dev

Android中的单独SOAP响应

来自分类Dev

Linq 在 List 中没有得到正确的值