Mam problem z biblioteka PEAR:SOAP w php 5 kiedy chcę przekazać jako argument zagnieżdżoną tablicę :
<?php
'proc' => 'COSTAM',
'LOGIN' => '111',
'PASSWORD' => '111',
)
);
#...
'namespace' => 'JAKIS_SYSTEM',
'soapaction' => false,
'timeout' => 120
);
#...
$this->soap_client = new SOAP_Client($strHost);
#...
$this->soap_client->call('login', $arguments, $params, -1);
#...
?>
Biblioteka traktuje to tak :
<ns4:login>
<proc xsi:type="xsd:string">COSTAM</proc>
<args xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[2]" SOAP-ENC:offset="[0]">
<item xsi:type="xsd:string">111</item>
<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 :
<?php
class DiaSoapClient extends SoapClient
{
public function __construct
($strHost, $strNamespace = '#', $strWSDL = null, $arrOptions = array()) {
parent
::__construct
($strWSDL, array( "location" => $strHost,
"uri" => $strNamespace,
"trace" => true
));
}
public function getLocation()
{
return $this->location;
}
public function setLocation($strLocation)
{
$this->location = $strLocation;
}
public function getNamespace()
{
return $this->uri;
}
public function setNamespace($strNamespace)
{
$this->uri = $strNamespace;
}
/**
* Przeciazenie pobierania atrybutow obiektu umozliwiajace latwe operowanie przestr
zeniami nazw
**/
private function __get($strNamespace)
{
$this->uri = $strNamespace;
return $this;
}
/**
* Przeciazenie wywolywania metod
*
* @todo Dodac inne mozliwosci wywolywania procedur
* @todo Rozszerzyc obsluge bledow
* @todo Dodac obsluge roznych typow zwracanych przez serwer
**/
public function __call($strMethodName, &$arrArguments)
{
$_arrArguments = array();
//
// Przekazano tablice
//
{
foreach($arrArguments[0] as $argumentName => $argumentValue)
{
$_arrArguments[] = (is_string($argumentName)) ?
new SoapParam
($argumentValue, $argumentName) : $argumentValue; }
}
//
// Wywolanie procedury
//
try {
$result = parent::__soapCall($strMethodName, $_arrArguments);
} catch (SoapFault $fault) {
$result = null;
}
return $result;
}
}
?>