2013-08-02 50 views
0

我已經找到了一個可靠的工作答案,找不到一個。在PHP中讀取一個簡單的SOAP XML響應

我也是SOAP新手,但對PHP很熟悉。

我送我的SOAP請求,捲曲我的回答回來這樣的:

<?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> 
<GetFeatureResponse xmlns="http://www.supportsite.com/webservices/"> 
    <GetFeatureResult>**string**</GetFeatureResult> 
</GetFeatureResponse> 
</soap:Body> 
</soap:Envelope> 

我需要保存的 - 在一個MySQL數據庫> GetFeatureResult「串」沒有XML。我所嘗試的一切都會返回空白這裏是我現在使用的:

$result = curl_exec($curl); 
curl_close ($curl); 

$resultXML = simplexml_load_string($result); 


$item = $resultXML->GetFeatureResponse->GetFeatureResult; 
+0

可能重複的:http://stackoverflow.com/questions/12485162/simplexml-load-string-will-not-閱讀肥皂響應與肥皂在標籤 – vee

+0

不是重複 - 我正在尋找一個具體問題的解決方案...該職位是模糊的問題,並沒有提出一個目標。因此,我收到的答案是在我的特定問題更有幫助 – Clandestine8

回答

1

PHP有一個內置的soap client。這很容易。只要您將其指向適當的WSDL文件,它就會返回一個可供使用的PHP對象。

編輯:挖出了一個例子,我有大約...

$sc = new SoapClient($wsdl, array(
    'location' => "https://$host:$port/path/", 
    'login' => $user, 
    'password' => $pass 
)); 

    //$sc will now contain methods (maybe properties too) defined by the WSDL file 
    //Getting the info you need could be as easy as 
    $info = $sc->getInfo(array('parameter'=>'value')); 
+0

然後使用$ Info = $ info-> GetInfoResult;設置變量。 – Clandestine8

+0

謝謝!我得到了它的工作 – Clandestine8