2017-08-28 151 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