2014-10-22 2 views
0

웹 검색과 많은 검색을 시도했지만 어떻게해야하는지 알 수 없습니다.PHP soap xml request

헤더와 XML 코드로 SOAP 요청을 만들고 싶습니다. 나는이처럼 보이는 보낼

$headers = array(
     "POST /somefile.asmx HTTP/1.1", 
     "Host: a ip adress", 
     "Content-Type: application/soap+xml; charset=utf-8", 
     "Content-Length: ".strlen($xml_post_string) 
    ); 

와 XML : 헤더 정보를 보유하고 변수 생성 :

이 어떻게 지금까지 내가 온 없습니다

<?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> 
    <GetViVaDataT xmlns="http://www.somesite.se/somefile.wsdl"> 
     <PlatsId>int</PlatsId> 
    </GetViVaDataT> 
    </soap:Body> 
</soap:Envelope> 

을하지만 난 더이 더 멀리 나아갈 생각. 나는 비누 1.2를 사용하고있다.

+0

스택 오버플로에 대한 다른 SOAP 질문이 있습니까? 예 : http://stackoverflow.com/questions/11502105/send-an-xml-request-to-a-another-web-server-using-soap-in-php?rq=1 –

+0

예, 있습니다. 저는 그것을 가지고 있습니다. cUrl로 테스트하는 오랜 시간이 지난 후에도 작업 할 수 있습니다 :) – zarex360

+1

그냥 게시하세요 :) – zarex360

답변

0

다른 사람들이 가지고있는 것과 동일한 문제가있는 경우 여기에 내가 작동하도록 한 것입니다.

$soapAction = 'http://www.somesite.com/path/to/file/file.wsdl/function'; 


    $xml = '<?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> 
     <GetViVaDataT xmlns="http://www.somesite.se/somefile.wsdl"> 
     <PlatsId>int</PlatsId> 
     </GetViVaDataT> 
    </soap:Body> 
    </soap:Envelope>'; 

    $headers = array(
     "POST /site.asmx HTTP/1.1", 
     "Host: a ip adress", 
     "Content-Type: application/soap+xml; charset=utf-8", 
     "Content-Length: ".strlen($xml), 
     'SOAPAction:' .$soapAction 
    ); 

    $curlData = $xml; 
    $url='http://site/file.asmx'; 
    $curl = curl_init(); 

    curl_setopt ($curl, CURLOPT_URL, $url); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($curl,CURLOPT_TIMEOUT,120); 
    curl_setopt($curl,CURLOPT_ENCODING,'xml'); 

    curl_setopt($curl,CURLOPT_HTTPHEADER,$headers); 

    curl_setopt ($curl, CURLOPT_POST, 1); 
    curl_setopt ($curl, CURLOPT_POSTFIELDS, $curlData); 

    $result = curl_exec($curl);