You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ephemeris Lappis <ep...@gmail.com> on 2005/06/15 13:38:18 UTC

Complex type / Javabean design

Hello.

This is a simple, perhaps stupid, question about how to design some kind of
javabeans to be good complex types for the wsdl and soap translation.

I have done some basic tests with simple flat, structure like javabeans with
primitive or 1-1 aggregated complex types. All this seems to work with Axis.

Now, i'm looking for more complex types with 1-n agregations. For instance
an "Order" and "Product line". The javabean convention let the bean designer
provide both agregate getter and setter, and indexed properties ones. In my
previous example, operations on my Order object could be something like :

	ProductLine[] getProductLines()
	void setProductLines(ProductLine[] pl)

to set or get the whole agregate. But indexed properties style methods could
also be :

	ProductLine getProductLine(int index)
	void setProductLine(ProductLine pl, int index)

I've tested something like that with axis (1.2 final), and the java2wsdl
produces a strange result. The Order type references two pseudo-attributes :
one for the array, mapping the first setter/getter set, and another one for
the indexed property...

In this case, or similar cases, does it make sense to design (or reuse) such
javabeans. If yes, is there any way to use the standard java2wsdl
translation (I know someone is going to quickly answer to wsdl it first !),
and standard serializers ?

Thanks for your comments.

--
Ephemeris Lappis


Re: Complex type / Javabean design

Posted by Davanum Srinivas <da...@gmail.com>.
yes. that looks right.

-- dims

On 6/15/05, Ephemeris Lappis <ep...@gmail.com> wrote:
> OK for the sentence !
> 
> Now, as i said before, if i remove the indexed property setter/getter (or in
> the original javabean, or hand-coding the wsdl), and just let the whole
> array getter/setter, the wsdl properly describes the sequence of complex
> type, and the serialization/deserialization seems to work.
> 
> With this complex type, describing an 'order' with a string and an array of
> products :
> 
>    <complexType name="ArrayOfProduct">
>     <sequence>
>      <element name="item" type="impl:Product" minOccurs="0"
> maxOccurs="unbounded"/>
>     </sequence>
>    </complexType>
> 
>         ...
> 
>    <complexType name="Order">
>     <sequence>
>      <element name="products" nillable="true" type="impl:ArrayOfProduct"/>
>      <element name="string" nillable="true" type="xsd:string"/>
>     </sequence>
>    </complexType>
> 
> The wsdl2java for the client produces a class with the same getter/setter
> that has my original javabean :
> 
>     public my.service3.CompositeBean[] getCompositeBeans() {
>         return compositeBeans;
>     }
> 
>     public void setCompositeBeans(my.service3.CompositeBean[]
> compositeBeans) {
>         this.compositeBeans = compositeBeans;
>     }
> 
> And, on the server side, my javabean setter/getter are properly used too by
> the serializer/deserializer.
> 
> So, it works !
> 
> But, is this the best or unique way to represent the 1-n associations ?
> 
> Thanks again for your comments.
> 
> >>> -----Original Message-----
> >>> From: Davanum Srinivas [mailto:davanum@gmail.com]
> >>> Sent: Wednesday, June 15, 2005 5:41 PM
> >>> To: axis-user@ws.apache.org
> >>> Subject: Re: Complex type / Javabean design
> >>>
> >>>
> >>> hehehe...WSDL First! :)
> >>>
> >>> -- dims
> >>>
> >>> On 6/15/05, Ephemeris Lappis <ep...@gmail.com> wrote:
> >>> > Hello.
> >>> >
> >>> > This is a simple, perhaps stupid, question about how to
> >>> design some kind of
> >>> > javabeans to be good complex types for the wsdl and soap translation.
> >>> >
> >>> > I have done some basic tests with simple flat, structure like
> >>> javabeans with
> >>> > primitive or 1-1 aggregated complex types. All this seems to
> >>> work with Axis.
> >>> >
> >>> > Now, i'm looking for more complex types with 1-n agregations.
> >>> For instance
> >>> > an "Order" and "Product line". The javabean convention let
> >>> the bean designer
> >>> > provide both agregate getter and setter, and indexed
> >>> properties ones. In my
> >>> > previous example, operations on my Order object could be
> >>> something like :
> >>> >
> >>> >         ProductLine[] getProductLines()
> >>> >         void setProductLines(ProductLine[] pl)
> >>> >
> >>> > to set or get the whole agregate. But indexed properties
> >>> style methods could
> >>> > also be :
> >>> >
> >>> >         ProductLine getProductLine(int index)
> >>> >         void setProductLine(ProductLine pl, int index)
> >>> >
> >>> > I've tested something like that with axis (1.2 final), and
> >>> the java2wsdl
> >>> > produces a strange result. The Order type references two
> >>> pseudo-attributes :
> >>> > one for the array, mapping the first setter/getter set, and
> >>> another one for
> >>> > the indexed property...
> >>> >
> >>> > In this case, or similar cases, does it make sense to design
> >>> (or reuse) such
> >>> > javabeans. If yes, is there any way to use the standard java2wsdl
> >>> > translation (I know someone is going to quickly answer to
> >>> wsdl it first !),
> >>> > and standard serializers ?
> >>> >
> >>> > Thanks for your comments.
> >>> >
> >>> > --
> >>> > Ephemeris Lappis
> >>> >
> >>> >
> >>>
> >>>
> >>> --
> >>> Davanum Srinivas -http://blogs.cocoondev.org/dims/
> 
> 


-- 
Davanum Srinivas -http://blogs.cocoondev.org/dims/

Interesting Error

Posted by J R <ca...@yahoo.com>.
I have created a service with the following client:

public class MyClient
{
   public static void main(String [] args) throws
Exception {
       Options options = new Options(args);

       String endpoint = "http://localhost:" +
options.getPort() +
                         "/axis/dummy/MyService.jws";


       Service  service = new Service();
       Call     call    = (Call) service.createCall();

       call.setTargetEndpointAddress( new
java.net.URL(endpoint) );
       call.setOperationName( "checkServer" );
       call.addParameter( "ipaddress",
XMLType.XSD_STRING, ParameterMode.IN );
       call.setReturnType( XMLType.XSD_STRING );

       System.out.println( call.invoke( new Object []
{ args[1] }) );

   }
}


The service uses threads and a network connection to
work correctly.

I get the following error message:
Exception in thread "main" AxisFault
 faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString:
java.lang.reflect.InvocationTargetException
 faultActor:
 faultNode:
 faultDetail:
       
{http://xml.apache.org/axis/}hostname:myhost.myserver.edu

java.lang.reflect.InvocationTargetException
        at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:221)
        at
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:128)
        at
org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
        at
org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown
Source)
        at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown
Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
        at
org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
        at
org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
        at
org.apache.xerces.parsers.XMLParser.parse(Unknown
Source)
        at
org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
Source)
        at
javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
        at
org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
        at
org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:645)
        at
org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
        at
org.apache.axis.message.addressing.handler.AddressingHandler.processClientResponse(AddressingHandler.java:305)
        at
org.apache.axis.message.addressing.handler.AddressingHandler.invoke(AddressingHandler.java:110)
        at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
        at
org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
        at
org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
        at
org.apache.axis.client.AxisClient.invoke(AxisClient.java:190)
        at
org.apache.axis.client.Call.invokeEngine(Call.java:2726)
        at
org.apache.axis.client.Call.invoke(Call.java:2709)
        at
org.apache.axis.client.Call.invoke(Call.java:2385)
        at
org.apache.axis.client.Call.invoke(Call.java:2308)
        at
org.apache.axis.client.Call.invoke(Call.java:1765)

The WSDL for my code is the following:
<wsdl:definitions
targetNamespace="http://localhost:8080/axis/dummy/MyService.jws">
-
	<!--
WSDL created by Apache Axis version: 1.2
Built on May 03, 2005 (02:20:24 EDT)
-->
-
	<wsdl:message name="checkServerResponse">
<wsdl:part name="checkServerReturn"
type="xsd:string"/>
</wsdl:message>
-
	<wsdl:message name="checkServerRequest">
<wsdl:part name="ipaddress" type="xsd:string"/>
</wsdl:message>
-
	<wsdl:portType name="MyService">
-
	<wsdl:operation name="checkServer"
parameterOrder="ipaddress">
<wsdl:input message="impl:checkServerRequest"
name="checkServerRequest"/>
<wsdl:output message="impl:checkServerResponse"
name="checkServerResponse"/>
</wsdl:operation>
</wsdl:portType>
-
	<wsdl:binding name="MyServiceSoapBinding"
type="impl:ArinWhois">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
-
	<wsdl:operation name="checkServer">
<wsdlsoap:operation soapAction=""/>
-
	<wsdl:input name="checkServerRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input>
-
	<wsdl:output name="checkServerResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost:8080/axis/dummy/MyService.jws"
use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
-
	<wsdl:service name="MyServiceService">
-
	<wsdl:port binding="impl:MyServiceSoapBinding"
name="MyService">
<wsdlsoap:address
location="http://localhost:8080/axis/dummy/MyService.jws"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

What could be causing this?  I am sure it is my fault.

JR


		
__________________________________ 
Discover Yahoo! 
Get on-the-go sports scores, stock quotes, news and more. Check it out! 
http://discover.yahoo.com/mobile.html

RE: Complex type / Javabean design

Posted by Ephemeris Lappis <ep...@gmail.com>.
OK for the sentence !

Now, as i said before, if i remove the indexed property setter/getter (or in
the original javabean, or hand-coding the wsdl), and just let the whole
array getter/setter, the wsdl properly describes the sequence of complex
type, and the serialization/deserialization seems to work.

With this complex type, describing an 'order' with a string and an array of
products :

   <complexType name="ArrayOfProduct">
    <sequence>
     <element name="item" type="impl:Product" minOccurs="0"
maxOccurs="unbounded"/>
    </sequence>
   </complexType>

	...

   <complexType name="Order">
    <sequence>
     <element name="products" nillable="true" type="impl:ArrayOfProduct"/>
     <element name="string" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>

The wsdl2java for the client produces a class with the same getter/setter
that has my original javabean :

    public my.service3.CompositeBean[] getCompositeBeans() {
        return compositeBeans;
    }

    public void setCompositeBeans(my.service3.CompositeBean[]
compositeBeans) {
        this.compositeBeans = compositeBeans;
    }

And, on the server side, my javabean setter/getter are properly used too by
the serializer/deserializer.

So, it works !

But, is this the best or unique way to represent the 1-n associations ?

Thanks again for your comments.

>>> -----Original Message-----
>>> From: Davanum Srinivas [mailto:davanum@gmail.com]
>>> Sent: Wednesday, June 15, 2005 5:41 PM
>>> To: axis-user@ws.apache.org
>>> Subject: Re: Complex type / Javabean design
>>>
>>>
>>> hehehe...WSDL First! :)
>>>
>>> -- dims
>>>
>>> On 6/15/05, Ephemeris Lappis <ep...@gmail.com> wrote:
>>> > Hello.
>>> >
>>> > This is a simple, perhaps stupid, question about how to
>>> design some kind of
>>> > javabeans to be good complex types for the wsdl and soap translation.
>>> >
>>> > I have done some basic tests with simple flat, structure like
>>> javabeans with
>>> > primitive or 1-1 aggregated complex types. All this seems to
>>> work with Axis.
>>> >
>>> > Now, i'm looking for more complex types with 1-n agregations.
>>> For instance
>>> > an "Order" and "Product line". The javabean convention let
>>> the bean designer
>>> > provide both agregate getter and setter, and indexed
>>> properties ones. In my
>>> > previous example, operations on my Order object could be
>>> something like :
>>> >
>>> >         ProductLine[] getProductLines()
>>> >         void setProductLines(ProductLine[] pl)
>>> >
>>> > to set or get the whole agregate. But indexed properties
>>> style methods could
>>> > also be :
>>> >
>>> >         ProductLine getProductLine(int index)
>>> >         void setProductLine(ProductLine pl, int index)
>>> >
>>> > I've tested something like that with axis (1.2 final), and
>>> the java2wsdl
>>> > produces a strange result. The Order type references two
>>> pseudo-attributes :
>>> > one for the array, mapping the first setter/getter set, and
>>> another one for
>>> > the indexed property...
>>> >
>>> > In this case, or similar cases, does it make sense to design
>>> (or reuse) such
>>> > javabeans. If yes, is there any way to use the standard java2wsdl
>>> > translation (I know someone is going to quickly answer to
>>> wsdl it first !),
>>> > and standard serializers ?
>>> >
>>> > Thanks for your comments.
>>> >
>>> > --
>>> > Ephemeris Lappis
>>> >
>>> >
>>>
>>>
>>> --
>>> Davanum Srinivas -http://blogs.cocoondev.org/dims/


Re: Complex type / Javabean design

Posted by Davanum Srinivas <da...@gmail.com>.
hehehe...WSDL First! :)

-- dims

On 6/15/05, Ephemeris Lappis <ep...@gmail.com> wrote:
> Hello.
> 
> This is a simple, perhaps stupid, question about how to design some kind of
> javabeans to be good complex types for the wsdl and soap translation.
> 
> I have done some basic tests with simple flat, structure like javabeans with
> primitive or 1-1 aggregated complex types. All this seems to work with Axis.
> 
> Now, i'm looking for more complex types with 1-n agregations. For instance
> an "Order" and "Product line". The javabean convention let the bean designer
> provide both agregate getter and setter, and indexed properties ones. In my
> previous example, operations on my Order object could be something like :
> 
>         ProductLine[] getProductLines()
>         void setProductLines(ProductLine[] pl)
> 
> to set or get the whole agregate. But indexed properties style methods could
> also be :
> 
>         ProductLine getProductLine(int index)
>         void setProductLine(ProductLine pl, int index)
> 
> I've tested something like that with axis (1.2 final), and the java2wsdl
> produces a strange result. The Order type references two pseudo-attributes :
> one for the array, mapping the first setter/getter set, and another one for
> the indexed property...
> 
> In this case, or similar cases, does it make sense to design (or reuse) such
> javabeans. If yes, is there any way to use the standard java2wsdl
> translation (I know someone is going to quickly answer to wsdl it first !),
> and standard serializers ?
> 
> Thanks for your comments.
> 
> --
> Ephemeris Lappis
> 
> 


-- 
Davanum Srinivas -http://blogs.cocoondev.org/dims/