Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SOAP] Problem z zagnieżdżonymi tablicami
prond
post 23.02.2007, 14:11:31
Post #1





Grupa: Zarejestrowani
Postów: 254
Pomógł: 10
Dołączył: 8.11.2006
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Mam problem z biblioteka PEAR:SOAP w php 5 kiedy chcę przekazać jako argument zagnieżdżoną tablicę :

  1. <?php
  2. $arguments = array(
  3. 'proc' => 'COSTAM',
  4. 'args' => array(
  5. 'LOGIN' => '111',
  6. 'PASSWORD' => '111',
  7. )
  8. );
  9.  
  10. #...
  11.  
  12. $params = array (
  13. 'namespace' => 'JAKIS_SYSTEM',
  14. 'soapaction' => false,
  15. 'timeout' => 120
  16. );
  17.  
  18. #...
  19.  
  20. $this->soap_client = new SOAP_Client($strHost);
  21.  
  22. #...
  23.  
  24. $this->soap_client->call('login', $arguments, $params, -1);
  25.  
  26. #...
  27. ?>


Biblioteka traktuje to tak :

  1. <ns4:login>
  2. <proc xsi:type="xsd:string">COSTAM</proc>
  3. <args xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[2]" SOAP-ENC:offset="[0]">
  4. <item xsi:type="xsd:string">111</item>
  5. <item xsi:type="xsd:string">111</item></args></ns4:login>


Czyli traktuje $arguments['args'] jako array, a nie hash.
Próbowałem to rozwiązać przekazując argumenty jako obiekt (z tym samym efektem).

Wcześniej ta procedura śmigała na serwerze z PHP 4.3.11, po zmianie PHP na 5.2.0 zachowuje się tak jak wyżej.

Udało mi się rozwiązać problem wykorzystując wbudowaną bibliotekę z PHP 5.2.0 :
  1. <?php
  2. class DiaSoapClient extends SoapClient
  3. {
  4.  
  5. public function __construct($strHost, $strNamespace = '#', $strWSDL = null, $arrOptions = array())
  6. {
  7. parent::__construct($strWSDL, array(
  8. "location" => $strHost,
  9. "uri" => $strNamespace,
  10. "trace" => true
  11. ));
  12. }
  13.  
  14. public function getLocation()
  15. {
  16. return $this->location;
  17. }
  18.  
  19. public function setLocation($strLocation)
  20. {
  21. $this->location = $strLocation;
  22. }
  23.  
  24. public function getNamespace()
  25. {
  26. return $this->uri;
  27. }
  28.  
  29. public function setNamespace($strNamespace)
  30. {
  31. $this->uri = $strNamespace;
  32. }
  33.  
  34. /**
  35.  * Przeciazenie pobierania atrybutow obiektu umozliwiajace latwe operowanie przestr
    zeniami nazw
  36.  **/
  37. private function __get($strNamespace)
  38. {
  39. $this->uri = $strNamespace;
  40.  
  41. return $this;
  42. }
  43.  
  44. /**
  45.  * Przeciazenie wywolywania metod
  46.  *
  47.  * @todo  Dodac inne mozliwosci wywolywania procedur
  48.  * @todo  Rozszerzyc obsluge bledow
  49.  * @todo  Dodac obsluge roznych typow zwracanych przez serwer
  50.  **/
  51. public function __call($strMethodName, &$arrArguments)
  52. {
  53. $_arrArguments = array();
  54.  
  55. //
  56. // Przekazano tablice
  57. //
  58. if (count($arrArguments) === 1 && is_array($arrArguments[0]))
  59. {
  60. foreach($arrArguments[0] as $argumentName => $argumentValue)
  61. {
  62. $_arrArguments[] = (is_string($argumentName)) ? new SoapParam($argumentValue, $argumentName) : $argumentValue;
  63. }
  64. }
  65.  
  66. //
  67. // Wywolanie procedury
  68. //
  69. try {
  70. $result = parent::__soapCall($strMethodName, $_arrArguments);
  71. } catch (SoapFault $fault) {
  72. $result = null;
  73. }
  74.  
  75. return $result;
  76. }
  77. }
  78. ?>


--------------------
--------------------------------------------------------------------------------
weblog.axent.pl
--------------------------------------------------------------------------------
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Sh4dow
post 5.03.2007, 11:01:13
Post #2





Grupa: Zarejestrowani
Postów: 569
Pomógł: 0
Dołączył: 17.08.2003
Skąd: Dąbrowa Górnicza

Ostrzeżenie: (0%)
-----


splatch ja osobiscie na chwile obecna nie uzywam wsdl'a i nie mam problemow z przesylaniem tablic obiektow czy innych wartosc. Wszystko co wysylam daje jako obiekt SoapVar to ze wsdl jest pomocny przy walidacji to jedno, ale jego brak nie podejzewam zeby powodowal tyle problemow.


--------------------
Warsztat: Linux: PHP, MySQL, Apache, NetBeans, C++, Qt-Creator
Użytkownik, słowo którego specjaliści IT używają, gdy chcą powiedzieć idiota
Zarządzaj swoim budżetem domowym
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 25.06.2025 - 12:23