我遇到SOAP Web Service和PHP的问题。我尝试连接到服务器并使用方法之一获取数据。我需要通过“NIP”值搜索结果。 首先,我的代码是:
$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异常:[a:DeserializationFailed]程序formatujący 查看更多详细信息: podczasdeserializacjitreścikomunikatużądanialadoperacji “GetMigrationDataExtendedAddressInfo”。 Oczekiwanogońcowegolementu “身体”z przestrzeni nazw“http://schemas.xmlsoap.org/soap/envelope/”。 Znaleziono元素“param1”z przestrzeni nazw“”。 Wiersz 2,pozycja 176 .. in ..
当我尝试:
$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”获取有关信封和搜索结果的信息(但我不知道如何使用它):
<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 :(得分:0)
参数:
$ params = array( '的authToken'=&GT; 'XXX', 'NIP'=&GT;阵列($参数));
响应:
$ response = $ soapclient-&GT; __的SOAPCall( “GetMigrationDataExtendedAddressInfo”, 阵列($ PARAMS));
答案 1 :(得分: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);