Re: WSIF and complex type

Jeff MAURY <jeffmaury-Zw62CLeTQR3qlBn2x/[email protected]> Fri, 07 Oct 2005 10:01:04 +0200
Newsgroups gmane.comp.apache.webservices.wsif.user
Message-ID <[email protected]>
[email protected] wrote:

> Hello
>  
>
> I?m not sure about that, when I need to consume services with complex 
> types I create beans that represent that complex type without using 
> specific serializer/deserializer info
>
Hello,

from my knowledge, Axis doesn't know by default how to 
serialize/deseriale custom bean. Are you using Axis or ApacheSOAP ? Even 
if you use the generic BeanSerializer/Deserialize from Axis, you have no 
guaranty that it will follow the order imposed by the sequence tag 
because it relies on Java reflection. The client ean generated by Axis 
implements a specific method that return the order of the properties.

Jeff

>  
>
> <xsd:complexType name="P001_CustomerSearch">
>
>   <xsd:sequence>
>
>     <xsd:element name="phone" type="tns:P001_Phone" />
>
>     <xsd:element name="central" type="tns:P001_Central" />
>
>     <xsd:element name="service" type="xsd:string" />
>
>     <xsd:element name="itpOrder" type="xsd:string" />
>
>     <xsd:element name="user" type="tns:P001_User" />
>
>   </xsd:sequence>
>
> </xsd:complexType>
>
>  
>
> Class:* *
>
> *public* *class* CustomerSearch  *implements* java.io.Serializable {
>
>     *private* Phone phone;
>
>     *private* Central central;
>
>     *private* String service;
>
>     *private* String itpOrder;
>
>     *private* User user;
>
>  
>
>     *public* CustomerSearch() {
>
>     }
>
>  
>
>     *public* Phone getPhone() {
>
>         *return* phone;
>
>     }
>
>  
>
>     *public* *void* setPhone(Phone phone) {
>
>         *this*.phone = phone;
>
>     }
>
>  
>
>     *public* Central getCentral() {
>
>         *return* central;
>
>     }
>
>  
>
>     *public* *void* setCentral(Central central) {
>
>         *this*.central = central;
>
>     }
>
>  
>
>     *public* String getService() {
>
>         *return* service;
>
>     }
>
>  
>
>     *public* *void* setService(String service) {
>
>         *this*.service = service;
>
>     }
>
>  
>
>     *public* String getItpOrder() {
>
>         *return* itpOrder;
>
>     }
>
>  
>
>     *public* *void* setItpOrder(String itpOrder) {
>
>         *this*.itpOrder = itpOrder;
>
>     }
>
>  
>
>     *public* User getUser() {
>
>         *return* user;
>
>     }
>
>  
>
>     *public* *void* setUser(User user) {
>
>         *this*.user = user;
>
>     }
>
> }
>
>  
>
> After this I map the type:
>
>  
>
> service.mapType(*new* QName(?http://www.xxxx.com.co/SA0018ns?, 
> ?P001_CustomerSearch?), 
> Class.forName(?co.com.xxxx.stub.sa0018.CustomerSearch?));
>
>  
>
> There is one problem if there are arrays inside complex types you may 
> have to use specific serializer/deserializer beans if it is is WS-I 
> complains. I found out to that if the service have the old style for 
> arrays like this you don need specific code
>
>  
>
> <xsd:complexType name="ArrayOfP001_CentralService">
>
>   <xsd:complexContent>
>
>     <xsd:restriction base="soapenc:Array">
>
>       <xsd:attribute ref="soapenc:arrayType" 
> wsdl:arrayType="tns:P001_CentralService[]" />
>
>     </xsd:restriction>
>
>   </xsd:complexContent>
>
> </xsd:complexType>
>
>  
>
> I think that you can check what type of arrays you need and you could 
> use wsdl2java to generate specific objects and use axis
>
>  
>
> I don?t see why you can not do it on the fly
>
>  
>
>  
>
> Juan David Pérez
>
>
> ___________________________________
> Juan David Pérez
> Assist
>
> -----Jeff MAURY <jeffmaury-Zw62CLeTQR3qlBn2x/[email protected]> wrote: -----
>
>     To: [email protected]
>     From: Jeff MAURY <jeffmaury-Zw62CLeTQR3qlBn2x/[email protected]>
>     Date: 10/06/2005 11:15AM
>     Subject: Re: WSIF and complex type
>
>     [email protected] wrote:
>
>>     Hello hello !
>>
>>      
>>
>>     So, most of you use the solution 1 (write your own SOAP client).
>>
>>     But, I?m wondering if the solution 2 (generate in fly stub class
>>     and use java.lang.Reflection to deal with stub) is easier than
>>     the solution 1.
>>
>     Hello,
>
>     well I don't think solution 2 should work. The reason is that WSIF
>     does not completely hide the underlying SOAP provider. For
>     example, if your SOAP provider is Axis, then you must add
>     serializer/deserializer information for your complex types that
>     will be used by Axis.
>     And even if you follow this step, you must ensure reflexion will
>     return the list of properties in the same order than the schema
>     from WSDL unless you specify a specific serializer for each
>     complex type.
>
>     Jeff
>
>>     Somebody can tell me if use WSIF or DII with generation of stub
>>     in fly is possible and easier than to write SOAP client?
>>
>>      
>>
>>     Sorry to disturb you, but I want to be sure before to begin
>>     develop my application.
>>
>>      
>>
>>     Thanks a lot
>>
>>      
>>
>>     Delphine.
>>
>>      
>>
>>     ------------------------------------------------------------------------
>>
>>     *De : *Bhuvan Gupta [ mailto:[email protected] ]
>>     *Envoyé : *mercredi 5 octobre 2005 17:58
>>     *À : *[email protected]
>>     *Objet : *Re: WSIF and complex type
>>
>>      
>>
>>     Hi,
>>
>>      
>>
>>     We have followed the same approach in creating a  generic version
>>     of "dynamic" WebService Consumer for FioranoESB
>>
>>     and it works with almost all the webservices (atleast the ones
>>     which are WS-I Basic Profile complaint).
>>
>>     We are using AXIS for Webservice invocation.
>>
>>     To give you a idea of what is done : 
>>
>>     1. Configuration :  There is a swing based Configuration Property
>>     Sheet contaiing following panels:
>>
>>         a) WSDL Panel - you specify WSDL or WSDL URL
>>
>>         b) Operation Panel - we parse the WSDL and show the list of
>>     operations available. User selects an operation here. 
>>
>>         c) Advanced Panel - It provides a table where you can
>>     specifiy advanced AXIS call properties like username/password for
>>     basic-authentication, configurations for WSSecurity etc
>>
>>     Once the configurations are complete, we generate request and
>>     response XSDs  (this XSD maps to the "complete" SOAPEnvelope
>>     which is to be sent as request and takes care of rpc-encoded and
>>     doc-literal cases)
>>
>>     2. Execution engine:
>>
>>         a) User send the XML complaint to the request XSD.
>>
>>         b) A call object is created based on the configured properties
>>
>>         c) Input XML is filled to the call object   
>>
>>         d) Operation is invoked
>>
>>         e) We deserialize the received response to XML
>>
>>        
>>
>>     I am sorry that I won't be able to share the source code for
>>     obvious reasons but I'll be more than happy to answer any
>>     technical queries.
>>
>>      
>>
>>     Thanks
>>
>>     Bhuvan
>>
>>      
>>
>>         ----- Original Message -----
>>
>>         *From: *Luca Baldi <mailto:[email protected]>
>>
>>         *To: *[email protected] <mailto:[email protected]>
>>
>>         *Sent: *Wednesday, October 05, 2005 9:11 PM
>>
>>         *Subject: *RE: WSIF and complex type
>>
>>          
>>
>>         Hi. I tried to use WSIF with complex types a few weeks ago,
>>         and decided that if you want to consume web services
>>         dynamically with complex types you?re better off starting
>>         from scratch. What I mean is that you can use Apache Axis (
>>         or SOAP ) library to create your SOAPMessage and populate it
>>         with whatever you want.
>>
>>         The steps that I take are the following;
>>
>>             * Read in the WSDL descriptor
>>             * Get the SOAP binding and list all the operations
>>               associated with the appropriate PortType
>>             * Pick an operation
>>             * Build input according to the WSDL descriptor
>>             * Create the request SOAPMessage and invoke the web service
>>             * Process the response SOAPMessage that comes back ( if
>>               you?re lucky, with no errors !! J ). What to expect is
>>               again based on the WSDL file
>>
>>          
>>
>>         It?s quite a complex process if you want to be able to handle
>>         any web service. I reckon the best approach would be to
>>         create the Body of the SOAPMessage as xml, and just add it to
>>         the SOAPBodyElement. Having said that, I haven?t done that
>>         for a variety of reasons ( which I am regretting a wee bit
>>         now ).
>>
>>         Basically if you follow your solution 1, you should be able
>>         to tackle this.
>>
>>          
>>
>>          
>>
>>         luca
>>
>>          
>>
>>         ------------------------------------------------------------------------
>>
>>         *From: *[email protected] [
>>         mailto:[email protected] ]
>>         *Sent: *05 October 2005 11:17
>>         *To: *[email protected]
>>         *Subject: *WSIF and complex type
>>
>>          
>>
>>         Hello everybody,
>>
>>          
>>
>>         I try to write a java GUI application which can invoke any
>>         Web Service (SOAP first).
>>
>>         Mecanism like
>>         http://www.strikeiron.com/analyzer/OnlineAnalyzer.aspx
>>         <http://www.strikeiron.com/analyzer/OnlineAnalyzer.aspx>
>>
>>          
>>
>>         I can parse and present graphically WSDL element on my java
>>         GUI, but, my problem is the COMPLEX TYPE !!!!
>>
>>         How can I manage complex type with WSIF?
>>
>>          
>>
>>         So I have many solutions:
>>
>>          
>>
>>         1 ? Write my own SOAP client (like this :
>>         http://www2.sys-con.com/ITSG/virtualcd/WebServices/archives/0310/behera/index.htm
>>         <http://www2.sys-con.com/ITSG/virtualcd/WebServices/archives/0310/behera/index.htm>)
>>
>>
>>          
>>
>>         2 ? Use JAX-RPC to use DII interface, generate in-fly the
>>         stub and use java.lang.Reflection to use these stubs.
>>
>>          
>>
>>         3 ? Use XSUL2 to use WSIF interface to send directly XML
>>         element for input, output and fault parameters.
>>
>>          
>>
>>         But, it seems that
>>
>>         1 ? It is difficult to write its own SOAP client because of
>>         many different encoding
>>
>>         2 ? I don?t really know how to do this
>>
>>         3 ? I try to use XSUL2 without success and the XSUL mailing
>>         list doesn?t return me any response of my problem (I have a
>>         xsul.wsif.WSIFException)
>>
>>         Details: no provider could be found for WSDL port <n1:port
>>         name="HelloIFPort" binding="tns:HelloIFBinding" xmlns:n1=
>>         "http://schemas.xmlsoap.org/wsdl/" >
>>
>>               < soap:address location=
>>         "http://dev2k15.dev.orsyp.com:8080/hello-dme/hello"
>>         xmlns:wsdl= "http://schemas.xmlsoap.org/wsdl/" xmlns:soap=
>>         "http://schemas.xmlsoap.org/wsdl/soap/" /></n1:port>
>>
>>          
>>
>>         So, I want to know if somebody resolves this issue of complex
>>         type with WSIF or with something else?.
>>
>>          
>>
>>         Any help or sample code will be appreciated.
>>
>>          
>>
>>         Thanks a lot.
>>
>>          
>>
>>         Delphine.
>>
>>          
>>
>>          
>>
>>          
>>
>>          
>>
>>          
>>
>>          
>>
>>          
>>
>>         ------------------------------------------------------------------------------------------------------------------------------------
>>         This email is intended for the exclusive use by the person(s)
>>         mentioned as recipient(s). If you receive this email by
>>         mistake, please notify the sender and delete this email
>>         immediately from your system and destroy all copies of it.
>>         You may not, directly or indirectly, use, disclose,
>>         distribute, print or copy this email or any part of it if you
>>         are not the intended recipient. This email and its
>>         attachments, if any, contain confidential information and/or
>>         may contain information protected by intellectual property
>>         rights or other rights. This email shall/may not be construed
>>         to constitute any commitment from Fiorano Software Inc. or
>>         its subsidiaries or affiliates except when expressly agreed
>>         to in a separate written agreement between the intended
>>         recipient and Fiorano Software Inc. or its subsidiaries or
>>         affiliates. Opinions, conclusions and other information
>>         expressed in this message are not given or endorsed by my
>>         firm or employer unless otherwise indicated by an authorized
>>         representative independent of this message. Unencrypted
>>         electronic mail is not secure, may contain harmful or
>>         virulent components or attachments and may not be authentic.
>>         Fiorano Software Inc. does not make any representations as to
>>         or the contents of this message nor for any damage caused by
>>         the use thereof.
>>         ------------------------------------------------------------------------------------------------------------------------------------
>>         Fiorano MailServer All incoming and outgoing mails are
>>         scanned for Virus http://www.fiorano.com
>>
>>     ------------------------------------------------------------------------------------------------------------------------------------
>>     This email is intended for the exclusive use by the person(s)
>>     mentioned as recipient(s). If you receive this email by mistake,
>>     please notify the sender and delete this email immediately from
>>     your system and destroy all copies of it. You may not, directly
>>     or indirectly, use, disclose, distribute, print or copy this
>>     email or any part of it if you are not the intended recipient.
>>     This email and its attachments, if any, contain confidential
>>     information and/or may contain information protected by
>>     intellectual property rights or other rights. This email
>>     shall/may not be construed to constitute any commitment from
>>     Fiorano Software Inc. or its subsidiaries or affiliates except
>>     when expressly agreed to in a separate written agreement between
>>     the intended recipient and Fiorano Software Inc. or its
>>     subsidiaries or affiliates. Opinions, conclusions and other
>>     information expressed in this message are not given or endorsed
>>     by my firm or employer unless otherwise indicated by an
>>     authorized representative independent of this message.
>>     Unencrypted electronic mail is not secure, may contain harmful or
>>     virulent components or attachments and may not be authentic.
>>     Fiorano Software Inc. does not make any representations as to or
>>     the contents of this message nor for any damage caused by the use
>>     thereof.
>>     ------------------------------------------------------------------------------------------------------------------------------------
>>     Fiorano MailServer All incoming and outgoing mails are scanned
>>     for Virus http://www.fiorano.com 
>
>
>