使用PHP Curl调用SOAP Web服务的问题

时间:2014-04-26 17:15:04

标签: php curl soap

我想使用以下代码获取SOAP结果,但返回“bool(false)”。你能指出以下代码中缺少的内容:


<?php
$credentials = "username:password";
$url = "_https://xxxx.rightnowdemo.com/cgi-bin/xxxx.cfg/services/chat_soap";
$body = '<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns oapenv="_http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="urn:messages.chat.ws.rightnow.com/v1_1">
   <soapenv:Header>
      <v1:ClientRequestHeader>
         <v1:AppID>Chatws</v1:AppID>
      </v1:ClientRequestHeader>
   </soapenv:Header>
   <soapenv:Body>
      <v1:GetChatOperatingHours/>
   </soapenv:Body>
</soapenv:Envelope>'; /// Your SOAP XML needs to be in this variable

$headers = array(
                 "Content-type: text/xml;charset=\"utf-8\"",
                "Accept: text/xml",
                "Cache-Control: no-cache",
                "Pragma: no-cache",
                "SOAPAction: GetChatOperatingHours",
                "Content-length: ".strlen($body),
   );
//load_curl();
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $credentials);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT']);
// Stuff I have added
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$data = curl_exec($ch);
curl_close($ch);
var_dump($data);

&GT;

欢迎任何意见/建议 谢谢, 苏雷什

0 个答案:

没有答案