2015-01-15 4 views
-2

저는 PHP에서 .NET으로 작성된 WebService 읽기 통합 작업을하고 있습니다.PHP SOAP WebService 지원

PHP Parse SOAP XML response from SOAP Client

나는 당신의 지원에 매우 감사하게 될 것입니다 : 나는 솔루션은 여기에 설명하지만 나를 위해 일하지 않았습니다 발견했다.

편집 :이 코드는 이미 내가 당신의 처리에 넣어 아래 내가 작업 한 https://stackoverflow.com/users/1987598/mathias-m%C3%BCller 마티아스 뮐러

코드 덕분에 수정했습니다

<?php 
error_reporting(E_ALL); 
ini_set('display_errors', 1); 
$wsdl = 'http://www.wsplaces.com/Xofigo/wsAppXofigo.asmx?WSDL'; 
$trace = true; 
$exceptions = false; 

$data = array(
    'IdEdo' => '9' 
); 

$client = new SoapClient($wsdl, array('trace' => $trace, 'exceptions' => $exceptions)); 
$response = $client->__soapCall("Get_PlacesByEdo", array($data)); 

echo"<pre>"; 
print_r($client); 
echo"</pre>"; 
echo"<pre>"; 
print_r($client->__last_response); 
echo"</pre>"; 

$lastResponse='<?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><Get_PlacesByEdoResponse xmlns="http://www.tempuri.org/"><Get_PlacesByEdoResult><IdEdo/></Get_PlacesByEdoResult></Get_PlacesByEdoResponse></soap:Body></soap:Envelope>'; 

$xml = new SimpleXMLElement($lastResponse); 
$xml->registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance'); 
$xml->registerXPathNamespace('xsd', 'http://www.w3.org/2001/XMLSchema'); 
$xml->registerXPathNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/'); 
$xml->registerXPathNamespace('xml', 'http://www.w3.org/XML/1998/namespace'); 
$xml->registerXPathNamespace('a', 'http://www.tempuri.org/'); 

$xpath ='/soap:Envelope/soap:Body/a:Get_PlacesByEdoResponse/a:Get_PlacesByEdoResult/a:IdEdo/text()'; 

$result = $xml->xpath($xpath); 

if ($result != FALSE && count($result) > 0) { 
     echo '{"reference": "' . $result[0] . '", "success":"true"}'; 
} else { 
     echo '{"error": "si", "success":"false"}'; 
} 


?> 
+0

작성한 내용에 어떤 문제가 있습니까? 어떤 오류가 발생하고 있습니까? 위의 코드로 인해 예기치 않은 동작이 발생했습니다> –

답변

0

XML 입력하지 않는 것 같다 입력 XML (더 읽기 쉬운 형식으로)이

<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> 
     <Get_PlacesByEdoResponse xmlns="http://www.tempuri.org/"> 
     <Get_PlacesByEdoResult> 
      <IdEdo/> 
     </Get_PlacesByEdoResult> 
     </Get_PlacesByEdoResponse> 
    </soap:Body> 
</soap:Envelope> 
처럼 보이기 때문에 a:Get_PlacesByEdo 요소를 포함합니다.

아마도 IdEdo 요소를 찾으려고했을 것입니까?

$xpath = '/soap:Envelope/soap:Body/a:Get_PlacesByEdoResponse/a:Get_PlacesByEdoResult/a:IdEdo/text()';--> 
-1

는 안녕하세요 비누 웹 서비스와 debute하고 난 probleme, ISEE 메시지 어레이 아래가 "공지 : \ WAMP \ WWW \ soapwebservice2 \ productlist.php 라인 18 불확정 변수 : HTTP_RAW_POST_DATA C하여"때 내가 "http://localhost/soapwebservice2/productlist.php"

+0

Pls 검토를 위해 코드 공유 :) –