Samuel Vogel wrote:
> Am 01.06.2009 20:05 Uhr, schrieb Shawn McKenzie:
>> Shawn McKenzie wrote:
>>
>>> 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();
>>>
>>>
>>
>> Doh! I just reread your post and see that you don't want to define all
>> the classes. That would be the best way to go. If not, most likely
>> you'll have to parse the xml and build the classes and eval() or look
>> for something already made, like:
>> http://code.google.com/p/wsdl2php-interpreter/downloads/list
>>
>>
> So a direct instantiation is not possible?
> Is there nothing like
>
> $test = new $ws->Credentials();
>
> or something?
>
> Regards,
> Samy
>
No.
--
Thanks!
-Shawn
http://www.spidean.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php