2014-01-22 28 views
1

由於我對SOAP很新,所以我真的需要一些幫助才能開始。我一直在考慮這個structur:按PHP中的給定請求和響應結構提供的SOAP響應

要求:

POST /NumbriParing/NumbriParing.asmx HTTP/1.1 
Host: nba.tja.ee 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "http://nba.sa.ee/NumriomanikuParing" 

<?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> 
    <NumriomanikuParing xmlns="http://nba.sa.ee/"> 
     <number>long</number> 
    </NumriomanikuParing> 
    </soap:Body> 
</soap:Envelope> 

響應:

HTTP/1.1 200 OK 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 

<?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> 
    <NumriomanikuParingResponse xmlns="http://nba.sa.ee/"> 
     <NumriomanikuParingResult> 
     <Number>long</Number> 
     <OmanikuRegNumber>string</OmanikuRegNumber> 
     <Omanik>string</Omanik> 
     <VastusKood>NumberLeitud or NumbritEiLeitud</VastusKood> 
     </NumriomanikuParingResult> 
    </NumriomanikuParingResponse> 
    </soap:Body> 
</soap:Envelope> 

我需要用一個數字變量來代替在請求中的 「長」 佔位符獲取該號碼的請求。 asmx位於https://nba.tja.ee/NumbriParing/NumbriParing.asmx 它如何使用PHP來完成?

最好的問候, 馬爾蒂·

回答

0

使用SoapClient,你需要該服務的WSDL。 類似於:

try { 
    $client = new SoapClient('https://nba.tja.ee/NumbriParing/NumbriParing.asmx?WSDL'); 
    $param = new stdClass(); 
    $param->number = 123; 
    $result = $client->NumriomanikuParing($param); 

    var_dump($result); 
} catch (Exception $e) { 
    echo "Error: " . $e->getMessage(); 
} 
+0

謝謝。有用。我無法想象SoapClient是如此容易使用。 –