0
我正在嘗試使用CURL調用SOAP webservice並且它不工作。這是我用來調用Web服務使用SOAP客戶端使用CURL調用SOAP WSDL Webservice
(object)$ProgramClient = new SoapClient('https://mywebserviceurl?wsdl',array(
'login' => "username", 'password' => "password",
'location' => 'https://someotherurl'
));
(object)$objResult1 = $ProgramClient->GetEvents(array (
'EventsRequest' => array (
'Source' => array (
'SourceId' => 'SOURCEID', 'SystemId' => 'SYTEMID')
)));
$event_info = $objResult1->EventsResponse;
這是工作的罰款,我使用curl轉換此調用的代碼,它停止工作。下面是一個使用我的代碼捲曲
$credentials = "username:password";
$url = "https://mywebserviceurl?wsdl";
$body = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetEvents xmlns="https://umywebserviceurl?wsdl">
</GetEvents >
</soap:Body>
</soap:Envelope>';
$headers = array(
'Content-Type: text/xml; charset="utf-8"',
'Content-Length: '.strlen($body),
'Accept: text/xml',
'Cache-Control: no-cache',
'Pragma: no-cache',
'SOAPAction: "GetEvents"'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
// Stuff I have added
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $credentials);
$data = curl_exec($ch);
echo '<pre>';
print_r($data);
誰能告訴我什麼,我在這裏失蹤..
問候 Jayesh
你能告訴我們錯誤嗎? – Tommy
我在curl_errorno()方法中得到0。 –
設置此選項「CURLOPT_VERBOSE」以獲取更多信息 – Tommy