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 Mauro Molinari <ma...@cardinis.com> on 2007/11/12 18:08:42 UTC
Array types and unwrapping
Hello all!
I just tried to generate Java client code from a WSDL with WSDL2Java
(Axis2 1.3). My WSDL has an element "strings" defined as:
<xsd:element name="strings" type="tns:ArrayOfStringsType"/>
<xsd:complexType name="ArrayOfStringsType">
<xsd:sequence>
<xsd:element name="item" type="xsd:string"
maxOccurs="unbounded" minOccurs="0">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
Suppose I have an operation whose response message output part refers to
"strings" element, using the "-uw" option of WSDL2Java I would expect
the following method to be generated:
public String[] myOperation(...){...}
Instead, the following method is generated:
public ArrayOfStringsType myOperation(...){...}
In other words, the ArrayOfStringsType complex type is not unwrapped.
This happens also if you have complex types with fields that are an
array of something. For instance, suppose you have a complex type AType
with the following fields:
- name: xsd:string
- strings: tns:ArrayOfStringsType
the generated AType wrapper has the following methods:
- public String getName() / public void setName(String)
- public ArrayOfStringsType getStrings() / public void
setStrings(ArrayOfStringsType)
while I would expect the second getter/setter pair to be:
- public String[] getStrings() / public void setStrings(String[])
Is there a way to obtain the unwrapping of arrays with Axis2? Or should
I edit the generated code manually?
Thanks in advance!
--
Mauro Molinari
Software Developer
mauro.molinari@cardinis.com
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Array types and unwrapping
Posted by Mauro Molinari <ma...@cardinis.com>.
Amila Suriarachchi ha scritto:
> if you do not bother about the wrapper elements do somthing like this,
> <xsd:element name="getVisiblePortfoliosResponse"
> type="txsns:ArrayOfCardinisPortfoliosType" />
I can try, although this approach leads to a document/literal unwrapped
stile WSDL, which could imply interoperability problems... I was
following IBM recommended way of writing WSDLs:
http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
This also does not solve the problem where a type refers to another type
which is an array (example: PortfolioCategoryType/fields element, which
leads to a PortfolioCategoryType.getFields() that returns an
ArrayOfOfStringsType instead of a String[]).
Do you think I could open a request enhancement for this?
--
Mauro Molinari
Software Developer
mauro.molinari@cardinis.com
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Array types and unwrapping
Posted by Amila Suriarachchi <am...@gmail.com>.
if you do not bother about the wrapper elements do somthing like this,
<xsd:element name="getVisiblePortfoliosResponse"
type="txsns:ArrayOfCardinisPortfoliosType" />
On Nov 14, 2007 1:33 PM, Mauro Molinari <ma...@cardinis.com> wrote:
> Amila Suriarachchi ha scritto:
> > On Nov 13, 2007 7:01 PM, Mauro Molinari <ma...@cardinis.com> wrote:
> > Here is the response element for this operation
> >
> > <xsd:element name="getVisiblePortfoliosResponse">
> > <xsd:complexType>
> > <xsd:sequence>
> > <xsd:element name="visiblePortfolios"
> > type="txsns:ArrayOfCardinisPortfoliosType">
> > </xsd:element>
> > </xsd:sequence>
> > </xsd:complexType>
> > </xsd:element>
> >
> > the unwrapping basically happens in one level. So the generated
> > method should take the visiblePortfolios as an argument.
> > For return types this happen only if inner complex type has one
> > element.
>
> Hi Amila,
> actually this is exactly the case: the visiblePortfolios element has
> just one element, an array of CardinisPortfoliosType in this case!
> In fact, the generated wrapper class ArrayOfCardinisPortfoliosType has
> an only "useful" method, getItem(), that returns that array ("item" is
> the name of the element in the ArrayOfCardinisPortfoliosType complex
> type definition). But WSDL2Java does not do the unwrapping.
>
> Do you suggest any other way to define and array in a document/literal
> wrapped style WSDL so that WSDL2Java can do the unwrapping?
>
> It would be VERY helpful, because working with these wrappers makes the
> code quite unconfortable to manage...
>
> --
>
> Mauro Molinari
> Software Developer
> mauro.molinari@cardinis.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
--
Amila Suriarachchi,
WSO2 Inc.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Array types and unwrapping
Posted by Mauro Molinari <ma...@cardinis.com>.
Amila Suriarachchi ha scritto:
> On Nov 13, 2007 7:01 PM, Mauro Molinari <ma...@cardinis.com> wrote:
> Here is the response element for this operation
>
> <xsd:element name="getVisiblePortfoliosResponse">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="visiblePortfolios"
> type="txsns:ArrayOfCardinisPortfoliosType">
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
>
> the unwrapping basically happens in one level. So the generated
> method should take the visiblePortfolios as an argument.
> For return types this happen only if inner complex type has one
> element.
Hi Amila,
actually this is exactly the case: the visiblePortfolios element has
just one element, an array of CardinisPortfoliosType in this case!
In fact, the generated wrapper class ArrayOfCardinisPortfoliosType has
an only "useful" method, getItem(), that returns that array ("item" is
the name of the element in the ArrayOfCardinisPortfoliosType complex
type definition). But WSDL2Java does not do the unwrapping.
Do you suggest any other way to define and array in a document/literal
wrapped style WSDL so that WSDL2Java can do the unwrapping?
It would be VERY helpful, because working with these wrappers makes the
code quite unconfortable to manage...
--
Mauro Molinari
Software Developer
mauro.molinari@cardinis.com
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Array types and unwrapping
Posted by Amila Suriarachchi <am...@gmail.com>.
On Nov 13, 2007 7:01 PM, Mauro Molinari <ma...@cardinis.com> wrote:
> Amila Suriarachchi ha scritto:
> > Can you please send your complete wsdl?
>
> Here it is!
> You can have a look at the generated return type of
> getVisiblePortfolios(String) or at the method
Here is the response element for this operation
<xsd:element name="getVisiblePortfoliosResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="visiblePortfolios"
type="txsns:ArrayOfCardinisPortfoliosType">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
the unwrapping basically happens in one level. So the generated
method should take the visiblePortfolios as an argument.
For return types this happen only if inner complex type has one
element.
Amila.
> PortfolioCategoryType.getFields().
>
>
> Thanks in advance!
>
> --
> Mauro Molinari
> Software Developer
> mauro.molinari@cardinis.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
--
Amila Suriarachchi,
WSO2 Inc.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Array types and unwrapping
Posted by Mauro Molinari <ma...@cardinis.com>.
Amila Suriarachchi ha scritto:
> Can you please send your complete wsdl?
Here it is!
You can have a look at the generated return type of
getVisiblePortfolios(String) or at the method
PortfolioCategoryType.getFields().
Thanks in advance!
--
Mauro Molinari
Software Developer
mauro.molinari@cardinis.com
Re: Array types and unwrapping
Posted by Amila Suriarachchi <am...@gmail.com>.
Can you please send your complete wsdl?
On Nov 12, 2007 10:38 PM, Mauro Molinari <ma...@cardinis.com> wrote:
> Hello all!
>
> I just tried to generate Java client code from a WSDL with WSDL2Java
> (Axis2 1.3). My WSDL has an element "strings" defined as:
>
> <xsd:element name="strings" type="tns:ArrayOfStringsType"/>
> <xsd:complexType name="ArrayOfStringsType">
> <xsd:sequence>
> <xsd:element name="item" type="xsd:string"
> maxOccurs="unbounded" minOccurs="0">
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
>
> Suppose I have an operation whose response message output part refers to
> "strings" element, using the "-uw" option of WSDL2Java I would expect
> the following method to be generated:
>
> public String[] myOperation(...){...}
>
> Instead, the following method is generated:
>
> public ArrayOfStringsType myOperation(...){...}
>
> In other words, the ArrayOfStringsType complex type is not unwrapped.
>
> This happens also if you have complex types with fields that are an
> array of something. For instance, suppose you have a complex type AType
> with the following fields:
> - name: xsd:string
> - strings: tns:ArrayOfStringsType
>
> the generated AType wrapper has the following methods:
> - public String getName() / public void setName(String)
> - public ArrayOfStringsType getStrings() / public void
> setStrings(ArrayOfStringsType)
> while I would expect the second getter/setter pair to be:
> - public String[] getStrings() / public void setStrings(String[])
>
> Is there a way to obtain the unwrapping of arrays with Axis2? Or should
> I edit the generated code manually?
>
> Thanks in advance!
>
> --
> Mauro Molinari
> Software Developer
> mauro.molinari@cardinis.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
--
Amila Suriarachchi,
WSO2 Inc.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org