RE: [PHP-SOAP-DEV] WSDLGenerator
Status: Alpha
Brought to you by:
rodif_bl
From: brad l. <rod...@ya...> - 2002-05-05 05:23:58
|
--- phpsurf <ph...@if...> wrote: > right, we are talking about several things here ! :) > > 1- wsdl auto-generation: > ok, good idea, I have no other experience of this (only played with java > implementation which is type specific ...) Yeah this topic is going to be hard. Im going to try and implements something here. Its not going to be as good as the java stuff becuase of the type stuff. but maybe it can adventuall be useful. Im not sure if you know this but you can currently bind your service to a existing wsdl. <? $server = new SoapServer(...); $server->bind("some_wsdl.wsdl"); $server->handle(); ?> This does a little magic. If your wsdl defines types in the schema part. php-saop will try and "convert" the type automatically according to the type in the wsdl. Say the wsdl defines <message name="getShort"> <part name="Result" type="xsd:short" /> </message> and the php function function getShort() { return "123"; } php-soap would return the message with the xsd:short type not the xsd:string. again this is only done when binding to a wsdl. This also works with complex types. <complexType name="someType"> <all> <element name="short" type="xsd:short" /> <element name="string" type="xsd:string" /> </all> </complexType> <message name="getType"> <part name="Result" type="someType" /> </message> function getType() { $ret->string = "some string"; $ret->short = "123"; $ret->double 1.3; return $ret; } php-soap will return the type as someType and add string as xsd:string and short as xsd:short but leave out the double. I think this is pretty flexable and powerfull, but this functionality is still pretty experimental. I need to get how that works documented. That also works on the client side. $soap = new SoapObject("somewsdl.wsdl"); $soap->echoShort("1234"); What i did just add today is the abilty to do this. http://server.com/some_php_service.php?WSDL (.net style) and if there is a wsdl bound to that service it will output the wsdl. > > 2- php/soap serialization/deserialization: > indeed wsdl defines the soap type of a soap parameter, but my point here is: > how to determine the corresponding php type ? > As they do in the Apache java implementation of soap, we could have a > mapping table that would associate each soap type with a php type ... and we > could also be able to define our own serializer/deserializer function ... > something that would tell php_soap (for a specific instance of soap server): > "every time you receive a soap type 'mySchemaSoapType' (as defined is the > schema part of the wsdl), deserialize it into the following php type > 'myPhpClass' (which would be an existing class, or any php type code), > using the deserializer handler 'mySoapToPhpDeserializerFunction' (wich is an > existing function)" > > this definition could run-time on client side and setup (a specific xml > document/ or comments in the code) on server side > or simply run-time on both client and server side ... > for example, one can define a bean_serializer which will only send via soap > attributes of an object that have a getter method ... > > maybe you could have a look at the Apache Implementation of Soap in Java to > see how they handled this problematic ... > I think their aproach is very attractive because it really let the developer > do what he wants with the soap implementation ... this is very powerfull ! > http://xml.apache.org/soap/index.html If the above small sample made any sence. the php-to-xml can be handled by using wsdls but the xml-to-php only seralizes to stdobjects and standard php types. A api would be pretty nice for this functionality. I do use apache soap i haven't go into the custom seriazlation. - Brad > > > > -----Original Message----- > > From: brad lafountain [mailto:rod...@ya...] > > Sent: mercredi 1 mai 2002 00:41 > > To: phpsurf; php...@li... > > Subject: RE: [PHP-SOAP-DEV] WSDLGenerator > > > > > > > > --- phpsurf <ph...@if...> wrote: > > > > > > > -----Original Message----- > > > > When php-soap starts generating wsdl's it is going to be soley > > > > dependant on the > > > > user documenting their code. phpdoc style. Otherwise the wsdl > > > > generator can't > > > > know types and parameters. > > > > Well I think we are talking about two differnt things here. > > 1) wsdl generation.. > > > > The wsdl has definintions about parameter types and return > > types. We all know > > php isn't type specfic. So for php-soap to be able to > > auto-generate wsdls it > > needs to know the types of parameters and the return values. So > > was looking > > into phpdoc and how to use that. > > > > /** > > Short Desc > > > > Long Desc > > > > @param name string description > > @param value string description > > @returns string description > > */ > > function do_something($name, $value) > > { > > return $name . $value; > > } > > > > if someone documents their code then php-soap can parse that file > > and pull the > > necessary information and genearte a wsdl from that. but that > > assumes that the > > developers are going to write their docuemntation correctly. Or i > > can write a > > script that will help the user guide thru a process of generating > > a wsdl. the > > "wizzard" will prompt them for parameters and return types. > > > > 2) php serialization / soap serialziation to and from native php and soap. > > Currently there is no way to override the way that it will > > seralize types. I do > > plan on creating an api to allow the users both on the client and > > server to > > override serialization. I havn't thought of a good way of doing > > it yet. But for > > the most part im pretty sure you wont need this. > > The way it currently works right now is. > > your wsdl defines this > > <schema> > > <s:element name="someObject"> > > <s:complexType> > > <s:element type="s:string" name="memberOne"> > > <s:element type="s:string" name="memberTwo"> > > </s:complexType> > > </s:element> > > </schema> > > and you have this code > > $server = new SoapServer(); > > $server->addFunction("returnSomeObject"); > > $server->bind("/wsdl/location/test.wsdl"); > > $server->handle(); > > > > function returnSomeObject() > > { > > $ret->memberOne = 'test'; > > $ret->memberTwo = 'test'; > > $ret->memberThree = 'test'; > > $ret->memberFour = 'test'; > > return ret; > > } > > > > now anytime someone invokes returnSomeObject it will only serialize > > memberOne and memberTwo and leave out memberFour and memberFive. > > and again with types it will auto convert types to the correct values. > > and with i don't know if you have seen SoapVar. But you can do > > something like > > this > > > > function getDateTime() > > { > > return new SoapVar(time(), XSD_DATETIME); > > } > > > > and that will serialize to the correct date time string that xsd defines. > > > > take alook at > > > > http://phpsoaptoolkit.sourceforge.net/phpsoap/guide/documentation/ > classes/soapvar/constructor/ > > > Does this make any sence. > > > If i still need to add a way to override serialziation then i will add it. I > just need to come up with a way to give the user a way to define it. > > > - brad > > > > > > are you talking about, for example, object creation from soap values, I > mean > > : how to transform a SoapValue into the apropriate PhpClass/Type ? > > > > I've been working a litle with the java Apache Soap implementation ... > > and they use, on the client side some kind of mapping table which is a > > property of each SoapClient. > > > > and on the server side, they use an xml file called "deployment > descriptor" > > to describe the java properties of the web services available on the > server. > > I know this server side on .Net is in the code comments likewhat you > suggest > > ... > > > > indeed, it's not really a question :) > > I just wanted to know your thinking about that ... > > > > > > > ____________________________________________________________________________ > __ > > ifrance.com, l'email gratuit le plus complet de l'Internet ! > > vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP... > > http://www.ifrance.com/_reloc/email.emailif > > > > > > > > _______________________________________________ > > Phpsoaptoolkit-development mailing list > > Php...@li... > > https://lists.sourceforge.net/lists/listinfo/phpsoaptoolkit-development > > > __________________________________________________ > Do You Yahoo!? > Yahoo! Health - your guide to health and wellness > http://health.yahoo.com > > > ______________________________________________________________________________ > ifrance.com, l'email gratuit le plus complet de l'Internet ! > vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP... > http://www.ifrance.com/_reloc/email.emailif > > > > _______________________________________________________________ > > Have big pipes? SourceForge.net is looking for download mirrors. We supply > the hardware. You get the recognition. Email Us: ban...@so... > _______________________________________________ > === message truncated === __________________________________________________ Do You Yahoo!? Yahoo! Health - your guide to health and wellness http://health.yahoo.com |