이것은 내 PHP 코드입니다.CURL 출력을 얻을 수 없습니다.
<?php
$xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<RequestList xmlns="http://tempuri.org/">
<category>syncapppr</category>
<subcategory>put_app_presc</subcategory>
<paralist>[{"app_List":[{"server_id":"","doctorid":"1266","patientid":"19569","prescriptionid":"870472109","parentid":"","parentserverid":"","FeesDue":"0","clinicid":"1273","caseno":"KAS-5712022016514","casetype":"","reason":"","note":"","diagnosis":"","adate":"22/07/2016","atime":"05:50 AM","fee":"300","refdoctorname":"","canceledbit":"false","rescheduledbit":"false","reschedule_reason":"","recschduledid":"","cancelled_reason":""}],"doc_id":"1266"}]</paralist>
</RequestList>
</soap12:Body>
</soap12:Envelope>';
$headers = array(
"Content-type: application/soap+xml; charset=utf-8",
"Content-length: ".strlen($xml_post_string),
);
$ch = curl_init();
$fh = fopen('soap_response.xml', 'w');
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, 'http://fakeurl.com/webservices/desktopservices.asmx?op=RequestList');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 100000000);
//curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FILE, $fh);
$response = curl_exec($ch);
//$xml = iconv("GB18030", "utf-8", $response);
$parser = simplexml_load_string(stripslashes($response));
$json = json_encode($parser);
echo($json);
curl_close($ch);
fclose($fh);
?>
내 스크립트를 실행할 때 오류가 발생합니다.
경고 :) (simplexml_load_string : 엔티티 : 라인 1 : 파서 오류 : 태그 예상 시작 '<'C에서 발견되지 \ XAMPP \ htdocs를 \ DsAdmin \ call_1.php 라인 41
경고 : simplexml_load_string() : 1의 C : \ XAMPP \ htdocs를 \ DsAdmin \ call_1.php 라인 41
경고^C에서 :) (simplexml_load_string \ XAMPP \ htdocs를 \ DsAdmin \ call_1.php 라인 41에
하지만 내가 볼 수 있듯이 파일 출력은 CURL 출력입니다. 영형. 그 파일에서 나는 정확한 출력을 얻고있다. 내 코드에서 무엇이 잘못되었는지 이해할 수 없다.
나는 그물에 많은 해결책을 심의했으나 아무런 효과가 없었으므로, 어떤 사람이 나를 도와 줄 수 있습니까?
파일 출력
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><RequestListResponse xmlns="http://tempuri.org/"><RequestListResult><syncapp_pres_list><SyncApp_Pres_Master><app_List><Appointment_Master><id>0</id><server_id>15238</server_id></Appointment_Master></app_List><startfrom>0</startfrom><endfrom>0</endfrom><clinicid>0</clinicid></SyncApp_Pres_Master></syncapp_pres_list></RequestListResult></RequestListResponse></soap:Body></soap:Envelope>
XML 한 줄로 시도 했습니까? – tanaydin
@tanaydin 님이 질문을받지 못했습니다. – Archish
$ xml_post_string에 문제가 생길 수있는 몇 줄의 새로운 줄이 있습니다. – tanaydin