2013-11-20 3 views
0

웹 서비스 호출에서 얻은 PHP의 XML 응답 구문 분석에 도움이 필요합니다. 파서의 유형은 실제로 중요하지 않습니다 (DOM/SAX/ETC ..). 그러나 XML 파일은 길지 않습니다. (최대 약 50 줄). simplexml_load_string을 사용했지만 데이터를 추출 할 수 없었습니다. 내가 생각하는 비누 또는 봉투 이름 공간과 관련이있다.PHP에서 비누 응답을 구문 분석하는 방법

응답은 :

<?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> 
<ProcessRequestResponse xmlns="http://xxxxxxxxx.yyy"> 
<ProcessRequestResult> 
<OutputData> 

&lt;?xml version="1.0" encoding="utf-8" ?&gt; 
&lt;DATA&gt; 
&lt;RECORD ID="1"&gt;&lt;COURSE_ID&gt;44226&lt;/COURSE_ID&gt;&lt;COURSE_NUMBER&gt;1234567-0&lt;/COURSE_NUMBER&gt;&lt;/RECORD&gt; 

&lt;RECORD ID="2"&gt;&lt;COURSE_ID&gt;44227&lt;/COURSE_ID&gt;&lt;COURSE_NUMBER&gt;1234598-0&lt;/COURSE_NUMBER&gt;&lt;/RECORD&gt; 

&lt;/DATA&gt; 
</OutputData> 
<ErrorMessage /> 
<Result>Success</Result> 
</ProcessRequestResult> 
</ProcessRequestResponse> 
</soap:Body> 
</soap:Envelope> 

이 내가 서버에서 얻고 있다는 정확한 반응이다.

이 XML을 구문 분석하도록 도와주세요! 나는 그 순간 정말로 분실했다.

수정 : 비누 바디를 수정하여 레코드 닫기 태그가 있어야합니다.

답변

0

SoapClient classmap option을 정의하여 SOAP 웹 서비스를 호출 해보십시오. 또한 html_entity_decode을 호출하고 simplexml_load_string을 호출하여 OutputData를로드해야합니다. 당신은 당신에게 호출 및 응답의 수신을 완화 것 PHP 생성기에 대한 WSDL을 시도 또한 살았어

, 같은 내가 한 방법 https://github.com/mikaelcom/WsdlToPhp

0

로, eway 비누 요청을 만들고 eway 비누 결과를 얻을 도움이 될 수 있습니다 다른 사람들!

<?php 
    $URL = "https://www.eway.com.au/gateway/rebill/test/manageRebill_test.asmx?wsdl"; 
       $option = array("trace"=>true); 
       $client = new SOAPClient($URL, $option); 
       $functions = $client->__getFunctions(); 
     $headeroptions=array('eWAYCustomerID'=>"87654321",'Username'=>"[email protected]","Password"=>"test123"); 
       $header = new SOAPHeader('http://www.eway.com.au/gateway/rebill/manageRebill', 'eWAYHeader',$headeroptions); 

       $bodyoptions = array(
           "CreateRebillCustomer" => array(
            "customerTitle" => "Mr",     
             "customerFirstName"=>"Muhammad", 
             "customerLastName"=>"Shahzad", 
             "customerAddress"=>"cust ome rAddress", 
             "customerSuburb"=>"customer Suburb", 
             "customerState"=>"ACT", 
             "customerCompany"=>"customer Company", 
             "customerPostCode"=>"2345", 
             "customerCountry"=>">Australia", 
             "customerEmail"=>"[email protected]", 
             "customerFax"=>"0298989898", 
             "customerPhone1"=>"0297979797", 
             "customerPhone2"=>"0297979797", 
             "customerRef"=>"Ref123", 
             "customerJobDesc"=>"customerJobDesc", 
             "customerComments"=>"customerComments",      
             "customerURL" => "http://www.acme.com.au" 
            ) 
           ); 

        try{ 
         $response = $client->__soapCall("CreateRebillCustomer", $bodyoptions,NULL,$header,$outputHeader); 
         //echo $client->__getLastRequest(); 
         //$response = $client->CreateRebillCustomer($bodyoptions); 
         //echo "<pre>";echo "<br/>"; 
         // print_r($response);   
          echo $result   = $response->CreateRebillCustomerResult->Result;echo "<br/>"; 
          echo $customerId  = $response->CreateRebillCustomerResult->RebillCustomerID;echo "<br/>"; 
          echo "<br/>"; 
         if($result=='Success' AND $customerId){ 
          echo 'Member Created at eWay Successfully!...<br/>'; 
          echo 'Creating Recurring Billing Cycle on eWay,Please wait......<br/>'; 
          //$UpdateRebillCustomer = CreateRebillEvent($customerId); 
          //print_r($UpdateRebillCustomer); 

         } 
         else{ 
          echo $ErrorSeverity = $response->CreateRebillCustomerResult->ErrorSeverity;echo "<br/>"; 
          echo $ErrorDetails = $response->CreateRebillCustomerResult->ErrorDetails;echo "<br/>"; 
         } 
        } 
        catch(SOAPFault $e){ 
         print $e; 
        } 

        if($customerId){ 


           $bodyoptions2 = array(
           "CreateRebillEvent " => array(
             "RebillCustomerID" => $customerId,     
             "RebillInvRef" => "Ref123", 
             "RebillInvDes"=>"description", 
             "RebillCCName"=>"Mr Andy Person", 
             "RebillCCNumber"=>"4444333322221111", 
             "RebillCCExpMonth"=>"12", 
             "RebillCCExpYear"=>"15", 
             "RebillInitAmt"=>"100", 
             "RebillInitDate"=>date('d/m/Y'), 
             "RebillRecurAmt"=>"200", 
             "RebillStartDate"=>date('d/m/Y'), 
             "RebillInterval"=>"31", 
             "RebillIntervalType"=>"1", 
             "RebillEndDate"=>"31/12/2013",      
            ) 
           ); 
         try{  
          $response = $client->__soapCall("CreateRebillEvent", $bodyoptions2,NULL,$header,$outputHeader); 
          //echo $client->__getLastRequest();   
          //print_r($response); 
          echo "<br/>"; 
           echo $result2  = $response->CreateRebillEventResult->Result;echo "<br/>"; 
           echo $RebillCustomerID = $response->CreateRebillEventResult->RebillCustomerID;echo "<br/>"; 
          if($result2=='Success'){ 
           echo 'Recurring Cycle Created Successfully at eWay!...<br/>'; 
           echo 'Member Id is ===>'.$RebillCustomerID; 
           //$UpdateRebillCustomer = CreateRebillEvent($customerId); 
           //print_r($UpdateRebillCustomer);       
          } 
          else{ 
           echo $ErrorSeverity = $response->CreateRebillEventResult->ErrorSeverity;echo "<br/>"; 
           echo $ErrorDetails = $response->CreateRebillEventResult->ErrorDetails;echo "<br/>"; 
          } 

         } 
        catch(SOAPFault $e){ 
         print $e; 
        } 

        } 

        ?> 
0
$xml = '<?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> 
        <ProcessRequestResponse xmlns="http://xxxxxxxxx.yyy"> 
         <ProcessRequestResult> 
          <OutputData>123</OutputData> 
          <ErrorMessage /> 
          <Result>Success</Result> 
         </ProcessRequestResult> 
        </ProcessRequestResponse> 
        </soap:Body> 
       </soap:Envelope>'; 
     $doc = new DOMDocument(); 
     $doc->loadXML($xml); 
     echo $doc->getElementsByTagName('OutputData')->item(0)->nodeValue; 

결과는 다음과 같습니다

3 
관련 문제