Re: [SOAP] php-soap interop
| From: | brad lafountain | Date: | Fri, 31 May 2002 19:36:30 +0000 |
| Subject: | Re: [SOAP] php-soap interop | ||
| References: | 1 | Groups: | php.soap |
| Request: | Send a blank email to php-soap+get-34@lists.php.net to get a copy of this message | ||
--- Shane Caraveo <shane@caraveo.com> wrote:
> brad lafountain wrote:
> >>Anyway, I need to get some script example from you. I want to start
> >>developing the interop tests. I can dig through some of the examples
> >>you've sent out before, but figure it would be easier to let you know
> >>what I need.
> >>
> >>a. send soap messages without wsdl, serializing php types directly
> >
> >
> > here is the default mapping:
> > php:long/int to xsd:long
> > php:double to xsd:double
> > php:string to xsd:string
> > php:bool to xsd:boolean
> > php:array to soap:array
> > php:array (with string keys) to apache:Map
> > php:object to soap:struct
>
> Hmm, so you have to use soapvar to create xsd:integer? I have found
> xsd:integer to be more used than xsd:long, and xsd:float more common
> than xsd:double. Anyway, it isn't important.
Yeah i realized that, it's a really simple change. I'll do that tonite.
>
> > Yeah the extension already knows how to encode all (most) xsd types, soap,
> > apache so it assumes the correct namespace.
>
> What about non-xsd types? It seems without wsdl there is no way to
> provide the element nodeName, namespace or type namespace.
My thinking here is if a server is soo type specfic that it wants long instead
of int or it has a specfic type. Then 99.9% of the time it will provied a wsdl.
>
> >
> >>Can you bind more than one class into a soap server? I have a couple
> >>interop classes that need to be bound to a server.
> >
> >
> > No.. the class binding is used for making a soap service a php object. So
> you
> > can use a object remotely and so the object can be perstisted.
> >
>
> The client side doesn't matter, but a small change in the server side
> would allow binding multiple classes, and allow for setting namespaces
> per-function when binding functions:
>
A small change to the API not as of a small change to the code.
> $server = new SoapServer();
> $server->setClass('myObject','urn:myobject');
> $server->setClass('anotherObject','urn:anotherobject');
> $server->addFunction('echoFloat','urn:echoFloat');
> $server->addFunction('echoSOAPStruct','urn:echoSOAPStruct');
> $server->handle();
>
> Then the client would change the namespace depending on what it is
> accessing:
>
> $obj = SoapObject("http://localhost/soapserver.php",
> "urn:myobject");
> echo $obj->someothermethod();
>
> $obj2 = SoapObject("http://localhost/soapserver.php",
> "urn:echoFloat");
> echo $obj2->echoFloat(1.2);
The SoapServer class was designed around it was available for one namespace
only (obvisouly). If you wanted 2 services you would create two SoapServers. To
get around this I was going to create a proxy type registry. Kinda how apache
soap does it. So you can 'register' many soap servers without having many php
files laying around.
Thinking more about your example it probally would make the proxy thing i was
talking about just a simple php script using the same api you defined. This
maybe the way to go.
<?
// i know this doesn't work but hey you get the point
// maybe even cache the proxy in shared memory or something.
$proxy = new SoapServer();
$config = new DomDocument("config.xml");
foreach($config->class as $class)
{
include_once($class->file);
$proxy->addClass($class->name, $class->uri);
}
foreach($config->functions as $function)
{
include_once($function->file);
$proxy->addFunction($function->name, $function->uri);
}
$proxy->handle();
?>
now you could create new soap services by editing a xml document and pointing
all of your endpoints to something like
http://server.com/phpsoap_proxy.php/urn:myObject
That look pretty interesting.... but how does wsdl binding work.
per urn or per soapserver. The wsdl binding right now is per server.
I can keep this in mind when im doing other things.... but i'd rather see some
other issues addressed first.
>
>
> I'm somewhat concered about the soapvar class, that it is too limited.
> I found that the minimal requirement to properly define types without
> wsdl is: name, type, value, type_namespace and optionaly a namespace.
> The combination of which build up to :
>
> <namespace_prefix:name
> xsi:type='type_namespace_prefix:type'
> xmlns:namespace_prefix='namespace'
> xmlns:type_namespace_prefix='type_namespace'
> >value</namespace_prefix:name>
>
> with the prefixes being autogenerated. It's easy to serialize xsd types
> without the additional information, but once you try to serialize
> SOAPStruct for instance, then you run into a problem if you cannot
> define these things.
>
> So perhaps the domxml work you've recently done addresses this, though
> dom seems heavy-wieght to me for doing simple serializations of complex
> types. If so, some examples on doing that would be helpfull. So here
> is a soap message that I will need to be able to serialize from a
You could deinflty do it with the stuff i just did. But you are right It
really wasn't designed for simple namespace stuff. It was more defined for
chaning the structure of the encoding.
> SoapObject call:
>
>
> http://www.caraveo.com/soap_interop/client_round2_results.php?wire=487
>
> From what I have seen so far, this would get me part way:
>
> //client
> $obj = new
>
> SoapObject('http://localhost/interopserver.php','http://soapinterop.org/');
> $inputStruct = new Std_Object();
> $inputStruct->varString = 'abcdefg';
> $inputStruct->varInt = SoapVar(1234,XSD_INT);
> $inputStruct->varFloat = SoapVar(1234,XSD_FLOAT);
> $ret = $obj->echoStruct($inputStruct);
>
>
> //server
> $server = new SoapServer('http://soapinterop.org/');
> $server->addFunction('echoStruct');
> $server->handle();
>
> function echoStruct($struct)
> {
> $retobj = new Std_Object();
> $retobj->varString = $struct->varString;
> $retobj->varInt = SoapVar($struct->varInt,XSD_INT);
> $retobj->varFloat = SoapVar($struct->varFloat,XSD_FLOAT);
> return $retobj;
> }
>
> What I am missing so far is how I define SOAPStruct is in the namespace
> http://soapinterop.org/xsd. If soapvar was changed to accept
> something
> like:
>
> return
> SoapVar($retobj,'{http://soapinterop.org/xsd}SOAPStruct');
Again.. if you server isn't using soapenc:Struct for any struct encoding then
ALOT of the time it would use a wsdl. And when using wsdl's all the type stuff,
encoding and ns are all behind the scenes.
php-soap does work without wsdl's but not for complex things. I didn't focus on
the non-wsdl part because i don't know too many servers that are complicated
structures or types that don't have wsdl's.
Don't get me wrong I do understand that it is usefull to have all of that
flexabilty for interop issues. But i was focusing on wsdls and making it
simple.
- Brad
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com