Re: Instantiate SOAP Request Objects
| From: | Shawn McKenzie | Date: | Mon, 01 Jun 2009 15:46:41 +0000 |
| Subject: | Re: Instantiate SOAP Request Objects | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-293430@lists.php.net to get a copy of this message | ||
Samuel Vogel wrote:
> Hey,
>
> I would like to know how I can instantiate the types that I get via the
> __getTypes() function or know if this is even possible.
> I am asking because I have a webservice in which all functions expect an
> specific object to be passed to them, rather than a list of arguments.
> And I am hoping that I do not have to code all those objects into my PHP
> Code, but rather instantiate them kinda from the wsdl!
>
> Here is what I have:
>
> $map = array('Credentials' => 'Credentials',
> 'GetSourceTextRequest'
> => 'GetSourceTextRequest');
> $ws = new
> SoapClient('http://192.168.0.1:8080/Service?wsdl',
> array('classmap' => $map));
>
> $test = new GetSourceTextRequest();
>
> It does not work this way however, I do get a class not found failure.
> How can I instantiate an object from SOAP?
>
> __getTypes() gives me something like this:
>
> struct Credentials {
> string Password;
> string Username;
> }
>
> Any hints would be appreciated!
>
> Regards,
> Samy
>
You are mapping SOAP types to PHP classes, so you need to define the PHP
class first:
class Credentials {
public $Password
public $Username
}
$map = array('Credentials' => 'Credentials', 'GetSourceTextRequest'
=>
'GetSourceTextRequest');
$ws = new SoapClient('http://192.168.0.1:8080/Service?wsdl',
array('classmap' => $map));
$test = new Credentials();
--
Thanks!
-Shawn
http://www.spidean.com