Witam,
mam problem ze skonstruowaniem wywołania funkcji SOAP.
Mam przykładowego XMLa, kiedy wywołuję go z programu SoapUI, dostaję prawidłową odpowiedź, więc XML wygląda na dobry.
Klienta SOAP na poziomie PHP mam też dobrze skonfigurowanrgo - inne funkcje dają dobre odpowiedzi.
Podejrzewam, że problem pojawia się na próbie przełożenia XML do parametru wywołania funkcji.
Zawartość XML:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:big="http://bik.pl/cc/big"> <soapenv:Header/> <soapenv:Body> <zapytanie-fin xmlns="http://bik.pl/cc/big" xmlns:ns2="http://bik.pl/cc/big/internal"> <naglowek> <dane-id nr-ref="111111" id-kli-im="1111111" id-jed-org-kli="1111111" id-operatora="QAZ123456" haslo-operatora="haslo" zn-danych-test="true" zn-powt-operacji="false"/> <typ-zapyt kod-rodz-zapyt="62" czas-zapyt="2014-10-07T08:18:00"/> </naglowek> <dane> <forma-pr-podm forma-pr-podm="01"/> <dane-id-kons seria-nr-dok-tozs="ab123456" rodz-dok-tozs="DO" pesel="78542125695" nazw="nazwisko" imie="imie" form-przek-nazw-i-im="01"/> <daty-upow data-up-24-1="2014-10-07T00:00:00" data-up-bik="2014-10-07T00:00:00" data-up-zbp="2014-10-07T00:00:00"/> </dane> </zapytanie-fin> </soapenv:Body> </soapenv:Envelope>
$nag = http://www.php.net/array ( "dane-id"=>array ( "nr-ref" => "111111", "id-kli-im"=>"1111111", "id-jed-org-kli"=>"1111111", "id-operatora"=>"QAZ123456", "haslo-operatora"=>"haslo", "zn-danych-test"=>"true", "zn-powt-operacji"=>"false" ), "typ-zapyt"=>array ( "kod-rodz-zapyt" => "62", "czas-zapyt" => "2014-10-07T08:18:00" ) ); $dane = http://www.php.net/array ( "forma-pr-podm" => http://www.php.net/array ( "forma-pr-podm" => "01" ), "dane-id-kons" => http://www.php.net/array ( "seria-nr-dok-tozs" => "ab123456", "rodz-dok-tozs" => "DO", "pesel" => "78542125695", "nazw" => "nazwisko", "imie" => "Imie", "form-przek-nazw-i-im" => "01" ), "daty-upow" => http://www.php.net/array ( "data-up-24-1" => "2014-10-07T00:00:00", "data-up-bik" => "2014-10-07T00:00:00", "data-up-zbp" => "2014-10-07T00:00:00" ) ); $param3 = http://www.php.net/array("naglowek"=>$nag ,"dane"=>$dane); try { $result = $client->__soapCall("nazwa_funkcji",http://www.php.net/array($param3)); http://www.php.net/print_r($result); } catch (SoapFault $exception) { http://www.php.net/echo $exception; }
http://stackoverflow.com/questions/15300843/creating-a-soap-call-using-php-with-an-xml-body
Dzięki za szybką odpowiedź.
Więc zrobiłem tak:
$xml = "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:big="http://bik.pl/cc/big"> <soapenv:http://www.php.net/header/> <soapenv:Body> <zapytanie-fin xmlns="http://bik.pl/cc/big" xmlns:ns2="http://bik.pl/cc/big/internal"> <naglowek> <dane-id nr-ref="111111" id-kli-im="1111111" id-jed-org-kli="1111111" id-operatora="QAZ123456" haslo-operatora="haslo" zn-danych-test="true" zn-powt-operacji="false"/> <typ-zapyt kod-rodz-zapyt="62" czas-zapyt="2014-10-07T08:18:00"/> </naglowek> <dane> <forma-pr-podm forma-pr-podm="01"/> <dane-id-kons seria-nr-dok-tozs="ab123456" rodz-dok-tozs="DO" pesel="78542125695" nazw="nazwisko" imie="imie" form-przek-nazw-i-im="01"/> <daty-upow data-up-24-1="2014-10-07T00:00:00" data-up-bik="2014-10-07T00:00:00" data-up-zbp="2014-10-07T00:00:00"/> </dane> </zapytanie-fin> </soapenv:Body> </soapenv:Envelope>"; $params = new \SoapVar($xml, XSD_ANYXML); try { $result = $client->__soapCall("nazwa_funkcji",array($params)); //$result = $client->Echo($params); print_r($result); } catch (SoapFault $exception) { echo $exception; }
SoapFault exception: [soap:Client] Parameter {http://schemas.xmlsoap.org/soap/envelope/}Envelope does not exist! in /var/strony/testy/soa/index.php:116 Stack trace: #0 /var/strony/testy/soa/index.php(116): SoapClient->__soapCall('nazwa_funkcji', Array) #1 {main}
$xml ujmij w ' zamiasj "
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:big="http://bik.pl/cc/big"> <soapenv:Header/> <soapenv:Body> <big:status-systemu> <big:typ-komunikatu>5</big:typ-komunikatu> </big:status-systemu> </soapenv:Body> </soapenv:Envelope>
$param = http://www.php.net/array("typ-komunikatu"=>5); $options = http://www.php.net/array( 'SOAPAction' => 'http://bik.pl/binari/ws/pobranie-rap-fin' ); try { $result = $client->__soapCall("status-systemu", http://www.php.net/array($param)); http://www.php.net/print_r($result); } catch (SoapFault $exception) { http://www.php.net/echo $exception; }
$xml2 = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:big="http://bik.pl/cc/big"> <soapenv:Header/> <soapenv:Body> <big:status-systemu> <big:typ-komunikatu>5</big:typ-komunikatu> </big:status-systemu> </soapenv:Body> </soapenv:Envelope>'; $param1 = new \SoapVar($xml2, XSD_ANYXML); try { $result = $client->__soapCall("status-systemu", http://www.php.net/array($param1)); http://www.php.net/print_r($result); } catch (SoapFault $exception) { http://www.php.net/echo $exception; }
SoapFault exception: [soap:Client] Parameter {http://schemas.xmlsoap.org/soap/envelope/}Envelope does not exist! in /var/strony/testy/soa/index.php:122 Stack trace: #0 /var/strony/testy/soa/index.php(122): SoapClient->__soapCall('status-systemu', Array) #1 {main}
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)