Re: Re: Mapping incoming object to PHP class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michael Rasmussen wrote:
> Have you tried static casting?
> $foe = new Foe;
> foe = (Foe) $SoapServer->getCustomerEntry();

Hello and thanks for the reply. I didn't completely understand what
you meant with static casting or your example.

Let me outline the structure of my simple test script here, so you
all may figure out what do I mean.

Thanks for help!

Ville

----

<?
####### server.php #######

class Contact {
	var $ID = 0;
	var $FirstName = "";
	var $LastName = "";
	var $PhoneNumber = "";
	
	function LoadContact($id) {
		// Loads the contact from the database per ID to
		// class variables ($this->FirstName)
	}
	
	function SaveToDB() {
		// Saves the data from class variables to the
		// database
	}
}

class PhonebookService {
	function GetContactById($id) {
		 $c = new Contact();
		 $c->LoadContact($id);
		 return $c;
	}
	
	function SaveContact($c) {
		// This is what would I like to do:
		$c->SaveToDB();

		// Anyway, calling this results
		// error that stdClass does not
		// have SaveToDB() function
	}
}

$server = new SoapServer("phonebook.wsdl");
$server->setClass("PhonebookService",
	array("classmap" =>
		array('Contact' => 'Contact'),
	));
	
$server->handle();
?>

####### phonebook.wsdl ########
(only part of the file to see the object definitions)
<types>
	<schema
targetNamespace='http://10.0.0.1/soaptest/phonebook.schema2'
xmlns='http://www.w3.org/2001/XMLSchema'>
		<complexType name="Contact">
			<sequence>
				<element name="ID" type="xsd:int" />
				<element name="FirstName" type="xsd:string" />
				<element name="LastName" type="xsd:string" />
				<element name="PhoneNumber" type="xsd:string" />
			</sequence>
		</complexType>
	</schema>
</types>

<message name='GetContactByIdRequest'>
  <part name='id' type='xsd:int'/>
</message>
<message name='GetContactByIdResponse'>
  <part name='Result' type='xsd2:Contact'/>
</message>
<message name='SaveNewContactRequest'>
  <part name='NewContact' type='xsd2:Contact'/>
</message>
<message name='SaveNewContactResponse'>
  <part name='NewID' type='xsd:string'/>
</message>

<portType name='PhonebookDataPortType'>
  <operation name='GetContactById'>
    <input message='tns:GetContactByIdRequest'/>
    <output message='tns:GetContactByIdResponse'/>
  </operation>
   <operation name='SaveContact'>
    <input message='tns:SaveNewContactRequest'/>
    <output message='tns:SaveNewContactResponse'/>
  </operation>
</portType>

########

-- 
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux