Re: Server return complex type

From: Date: Fri, 18 Jul 2003 13:42:04 +0000
Subject: Re: Server return complex type
References: 1  Groups: php.soap 
Request: Send a blank email to php-soap+get-857@lists.php.net to get a copy of this message
Hi, apparently, PEAR::SOAP can't currently handle conversion between internal variables/objects to XML ComplexTypes in a totally automated way. So, if you do your server functions returning something like: a = new Rectangle; a->TopLeft = new Point(1, 1); a->BottomRight = new Point(10, 10); return a; you'll get the Rectangle type correctly mapped (if you defined a typemap) but the TopLeft and BottomRight won't: <return xsi:type="ns4:RectangleType"> <TopLeft> <X xsi:type="xsd:integer">1</X> <Y xsi:type="xsd:integer">1</Y> </TopLeft> <BottomRight> <X xsi:type="xsd:integer">10</X> <Y xsi:type="xsd:integer">10</Y> </BottomRight> <return> In order to get the expected behaviour you have to *explicitly* assign a XML complexType to TopLeft and BottomRight using a SOAP_Value to enforce mapping: a = new Rectangle; a->TopLeft = new SOAP_Value('TopLeft', '{YourURN}PointType', new Point(1, 1)); a->BottomRight = new SOAP_Value('BottomRight', '{YourURN}PointType', new Point(10, 10)); return a; this way you'll get: <return xsi:type="ns4:RectangleType"> <TopLeft xsi:type="ns4:PointType"> <X xsi:type="xsd:integer">1</X> <Y xsi:type="xsd:integer">1</Y> </TopLeft> <BottomRight xsi:type="ns4:PointType"> <X xsi:type="xsd:integer">10</X> <Y xsi:type="xsd:integer">10</Y> </BottomRight> <return> (at least this worked for me...) The PEAR::SOAP guys already did an excellent job (SOAP isn't really a "simple" protocol, it's quite the contrary...). However, in order to enhance interoperability between systems, there's probably the need for more "intelligence" in the type conversion routines to improve automatic typemapping (type registration, etc). Hoping that it helps. Michele "Will Green" <will@hotgazpacho.org> ha scritto nel messaggio news:20030716184248.56821.qmail@pb1.pair.com... > Can anyone point me in the direction of some documentation or a HOWTO on > creating a SOAP server using PEAR::SOAP that can return a complex type? > > Perhpas even just an overview of the concepts involved in creating such a > service would do. > > I've looked over Shane's various SOAP presentations on talks.php.net, but I must > be missing something, becuase I just don't quite get it. Should I have a class > for each complex type? If so, must these classes have any specific methods or > properties in order to work correctly? How do these classes relate to the > server class I will need to create? > > Specifically, I am trying to implement this service: > > http://demo.soapam.com/services/FedEpayDirectory/ > > on my own machine (since this one is just a demo, and I need the service for a > production project). I already have a local copy of the database that I can run > queries against. I just need to know how to accept messages with complex types, > and return a message consisting of the results of a query on the database in > another, different complex type, both according to the documentation at the URL > above. > > I want to implement this as a warm-up for another service that I will be > creating from scratch later. Don't misunderstand me... I don't want someone to > re-implement this for me... I just want some guidance in how to propperly > implement this myself as a way of learning PEAR::SOAP. > > Once I have an understanding of how to implement a web service with PEAR::SOAP, > I'll gladly post some documentation on the concepts and the processes to my web > site (who knows... this may be the start of some actual documentation for > PEAR::SOAP). > > Any and all help would be greatly appreciated. > > == > Will Green >

« previous php.soap (#857) next »