phpbar.de logo

Mailinglisten-Archive

[php] WSDL-Webservice mit Object als Parameter....

[php] WSDL-Webservice mit Object als Parameter....

Jens Reinemuth openos at gmx.de
Don Jul 27 09:25:36 CEST 2006


On Thursday 27 July 2006 07:29, Peter Webel wrote:
> morgen jens,
>
> nochwas, wie sieht den dein aufruf der wsdl-funtion aus.
> ich hab die erfahrung gemacht das es am besten mit
>
> $client->__soapCall("soapfunction",$ar_soapfunctionparam);
>
> mit $clint->soapfunction($ar_soapfunctionparam);
>
> hatte ich manchesmal probleme.
>
> so long
> mfg Peter

Hallo Peter...

Wie gesagt, egal ob als Array oder als Object... SOAP schneidet nach dem 
ersten Property ab...

-------------------------------------------------------
Was bekommt der Webservice:
-------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns1="http://ws.personnel.adato.com/">
<SOAP-ENV:Body>
<ns1:addAppointment>
	<arg0>
		nhhp0j7j0j3354dalhfg96u7t2
	</arg0>
	<arg1>
		<id>
			10006
		</id>
	</arg1>
</ns1:addAppointment>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

-------------------------------------------------------
Response...
-------------------------------------------------------
<?xml version="1.0" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:ns1="http://ws.personnel.adato.com/">
<soapenv:Body>
<ns1:addAppointmentResponse>
	<return>
		At least one parameter is null
	</return>
</ns1:addAppointmentResponse>
</soapenv:Body>
</soapenv:Envelope>


SOAP ist in eine Klasse gekapselt, ich versuchs mal kurz wiederzugeben:

-------------------------------------------------------
Aufruf
-------------------------------------------------------
.
.
.
$arrVon = explode('.',$_POST['von']);
$arrBis = explode('.',$_POST['bis']);
$tsVon = mktime(0,0,0,$arrVon[1],$arrVon[0],$arrVon[2]);
$tsBis = mktime(0,0,0,$arrBis[1],$arrBis[0],$arrBis[2]);
$tsVon .= '000'; // Java benutzt microseconds...
$tsBis .= '000'; // Java benutzt microseconds...
$valObj->id 		= '10006';
$valObj->name	= session_id();
$valObj->von		= $tsVon;
$valObj->bis		= $tsBis;
$valObj->kategorie= '0';
$valObj->typ		= '4';
$arrParams = array ('arg0'=>session_id(),'arg1'=>$valObj);
print_r($arrParams);
print '<br />';
$retVal = $mySOAP->queryWebService('CalendarService','addAppointment',
$arrParams);
.
.
.
-------------------------------------------------------
SOAP-Class (ich denke aP_I18N spar ich mir... ;-))
-------------------------------------------------------
.
.
.
public function soapConnect($strService) {
		try {
			if (!$this->soapObject = new SoapClient($this->soapServer.
$strService.'Service/'.$strService.'?WSDL',$this->soapNS)) {
				throw new exception;
			} else {
				//$this->soapObject->__getFunctions();
				return (true);
			}
		} catch (exception $e) {
			$arrVars = array($strService);
			$this->soapError=aP_I18N::getText('soap_servererror',$arrVars);
			return (false);
		}
	}
	
	public function soapDisconnect($strService) {
		unset ($this->soapObject);
	}
	
	public function soapCall ($strMethod,$arrParameter) {
		$retVal = '';
		try {
			$retVal = $this->soapObject->$strMethod($arrParameter);
		} catch (SoapFault $fault) {
			$arrVars = array($strMethod);
			$this->soapError=aP_I18N::getText('soap_serviceerror',$arrVars);
			$retVal = false;
		}
		return($retVal);
	}

	public function queryWebService($strServiceName,$strFunction,$arrParams) {
		$retVal = '';
		$error=0;
		if ($this->soapConnect($strServiceName)) {
			$params = $arrParams;
			$return = $this->soapCall($strFunction,$params);
			if ($return!==false) {
				$retVal = $return;
			} else {
				$error=1;
			}
		} else {
			$error=1;
		}
		if ($error==1) {
			$retVal = '
			<div id="error">
			<table class="error" cellpadding="0" cellspacing="0" border="0">
			<tr>
				<td class="error" rowspan="2"><img src="./share/images/warning.gif" 
border="0" /></td>
				<td class="errorheader">'.aP_I18N::getText('soap_error').'</td>
			</tr>
			<tr>
				<td class="error">
				'.$this->soapError.'
				</td>
			</tr>
			</div>
			';
		}
		return($retVal);
	}
.
.
.


-- 
jens reinemuth
pfluegersgrundstr. 23
68169 mannheim
+49 (621) 167 99 39
jens at openos.de
--
The answer to the question of Life, the Universe, and Everything is...

	Four day work week,
	Two ply toilet paper!

php::bar PHP Wiki   -   Listenarchive