2017-08-28 152 views
1

獲得PHP日期我有一個SOAP Web服務和PHP的一個問題。我嘗試使用一種方法連接到服務器。我需要搜索和結果「整容」的價值。 首先,我的代碼是:從SOAP Web服務

$wsdl = 'https://datastoretest.ceidg.gov.pl/CEIDG.DataStore/Services/NewDataStoreProvider.svc?singleWsdl'; 
$data = array(
    "AuthToken" => "xxx", 
    "NIP" => "6332212511" 
); 
$soap = new SoapClient($wsdl, array('trace' => true, 'exception' => true)); 
$response = $soap->__soapCall("GetMigrationDataExtendedAddressInfo", $data); 
print_r($resopnse); 

和錯誤看起來像

的SOAPFault例外:一:DeserializationFailed]格式化 拋出一個異常,而試圖反序列化消息:發生錯誤 反序列化操作 內容請求消息「GetMigrationDataExtendedAddressInfo」。預計最終的元素 「身體」命名空間「http://schemas.xmlsoap.org/soap/envelope/」。 元素中找到「參數1」命名空間「」。 2號線,在 176位置..

當和嘗試:

$soap->__getTypes(); 
$soap->__getFunctions(); 

結果是:

Array 
(
    [0] => struct GetID { 
string AuthToken; 
dateTime DateFrom; 
dateTime DateTo; 
dateTime MigrationDateFrom; 
dateTime MigrationDateTo; 
} 
    [1] => struct GetIDResponse { 
string GetIDResult; 
} 
    [2] => struct GetMigrationDataExtendedAddressInfo { 
string AuthToken; 
ArrayOfstring NIP; 
ArrayOfstring REGON; 
ArrayOfstring NIP_SC; 
ArrayOfstring REGON_SC; 
ArrayOfstring Name; 
ArrayOfstring Province; 
ArrayOfstring County; 
ArrayOfstring Commune; 
ArrayOfstring City; 
ArrayOfstring Street; 
ArrayOfstring Postcode; 
dateTime DateFrom; 
dateTime DateTo; 
ArrayOfstring PKD; 
ArrayOfint status; 
ArrayOfstring UniqueId; 
dateTime MigrationDateFrom; 
dateTime MigrationDateTo; 
} 
    [3] => struct GetMigrationDataExtendedAddressInfoResponse { 
string GetMigrationDataExtendedAddressInfoResult; 
} 
    [4] => int char 
    [5] => duration duration 
    [6] => string guid 
    [7] => struct ArrayOfstring { 
string string; 
} 
    [8] => struct ArrayOfint { 
int int; 
} 
) 
Array 
(
    [0] => GetIDResponse GetID(GetID $parameters) 
    [1] => GetMigrationDataExtendedAddressInfoResponse GetMigrationDataExtendedAddressInfo(GetMigrationDataExtendedAddressInfo $parameters) 
    [2] => GetIDResponse GetID(GetID $parameters) 
    [3] => GetMigrationDataExtendedAddressInfoResponse GetMigrationDataExtendedAddressInfo(GetMigrationDataExtendedAddressInfo $parameters) 
) 

我有包膜和搜索結果爲 「NIP」 信息從這個Web服務的文檔(但我不知道如何使用它):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:tem="http://tempuri.org/" 
xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> 
<soapenv:Header/> 
<soapenv:Body> 
<tem:GetMigrationDataExtendedAddressInfo> 
<tem:AuthToken>xxx</tem:AuthToken> 
<tem:NIP> 
<arr:string>6332212511</arr:string> 
</tem:NIP> 
</tem:GetMigrationDataExtendedAddressInfo> 
</soapenv:Body> 
</soapenv:Envelope> 
那麼,什麼

與錯? :(請幫助我解決這個問題

+0

我覺得應該是'$響應= $肥皂 - > __的SOAPCall(「GetMigrationDataExtendedAddressInfo」,陣列($數據)); – Amir

+0

'是。它正在工作,但是「沒有幹帳」。所以,可能問題是將參數作爲$ data發送。 AuthToken沒問題,因爲服務讓我進來。 – MateuszRyaN

+0

你要解決這個問題?此外,我得到的消息「沒有用戶帳戶」 – danny3b

回答

0

由於這樣的事實,我有越來越多的私人調查,我提出以下解決方案。該代碼到目前爲止一直爲所有人工作。如果你有這個代碼的問題,你可能有東西堵塞/防火牆/ PHP升級到新的版本/檢查,如果你有肥皂的phpinfo()函數:)

error_reporting(E_ERROR | E_WARNING | E_PARSE); 
$arrLocales = array('pl_PL', 'pl','Polish_Poland.28592'); 
setlocale(LC_ALL, $arrLocales); 
date_default_timezone_set('Europe/Warsaw'); 
set_time_limit(0); 

function XML2Array(SimpleXMLElement $parent) { 
    $array = array(); 
    foreach ($parent as $name => $element) { 
     ($node = & $array[$name]) 
      && (1 === count($node) ? $node = array($node) : 1) 
      && $node = & $node[]; 
     $node = $element->count() ? XML2Array($element) : trim($element); 
    } 
    return $array; 
} 

$wsdl = 'https://datastore.ceidg.gov.pl/CEIDG.DataStore/services/NewDataStoreProvider.svc?singleWsdl'; 
$nip = array("1112223344"); 
$token = 'CEIDG_TOKEN'; 
$data = array(
    "AuthToken" => $token, 
    "NIP"  => $nip, 
); 

$soap = new SoapClient($wsdl); 
$resp = $soap->__soapCall("GetMigrationDataExtendedAddressInfo",array($data)); 

$array = json_decode(json_encode($resp), true); 

$wpis = $array['GetMigrationDataExtendedAddressInfoResult']; 
$xml = simplexml_load_string($wpis); 
$xml_array = unserialize(serialize(json_decode(json_encode((array) $xml), 1))); 
print_R($xml_array); 
0

參數:

$陣列PARAMS =( '的authToken'=> 'XXX' 'NIP'=>陣列($參數))。

響應:

$響應= $ SoapClient的 - > __的SOAPCall( 「GetMigrationDataExtendedAddressInfo」 陣列($ PARAMS));

+0

我已知道,我來了:)不過感謝您的關注。 – MateuszRyaN