You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Raj Floyd <ra...@gmail.com> on 2011/03/15 13:27:40 UTC
wsdl2java: ObjectFactory
Hi,
When I use wsdl2java with either client or server option, it generates
ObjectFactory class, XX and XXResponse classes. Why are these classes
generated and where it could be useful?
Thx
Raj
Re: wsdl2java: ObjectFactory
Posted by Ron Wheeler <rw...@artifact-software.com>.
On 15/03/2011 1:54 PM, Raj Floyd wrote:
> Thanks Ron.
>
> I am specifically interested in CXF framework. Like I understand your
> point but the only reason I am going into details is that I can
> understand the Web service better as a product or a technology. There
> are several concepts like JAXWS, JAXB, WSDL, Schemas....etc and each
> plays a significant role in the Web service infrastructure per say.
> And there are plenty of Web service based use cases which most of the
> people (specially ones like me) don't even know.
>
> I am just going a bit far as I can understand the semantics of this
> framework (CXF) better and therefore also understand the Web service
> as a technology better.
>
> My apologies if that has confused you. I am just kinda researching and
> it can just make me more better equipped to use Web services in projects.
No problem. I was just a bit concerned that you were going to get
frustrated before you had a chance to get something working.
We have been using CXF for over a year now in a production e-Learning
portal that servers over 8000 students.
We added Web Services after we had the portal in production so it had to
go from test to production without a hitch and work well as it had the
day earlier (only faster).
We looked at Axis and CXF and chose CXF because it seemed to be packaged
in a way that kept us from having to invest a lot in learning the
underlying plumbing.
We have been very happy with both performance and ease of development.
There is nothing wrong with the investigation that you are doing and I
am sure that it will give you a higher level of confidence with what you
are about to build.
I am just not sure where the law of diminishing returns sets in with
learning CXF internals since so much seems to work so well right out of
the box if one follows the examples and the documentation.
Ron
>
> Thx
>
> Raj
>
> On Tue, Mar 15, 2011 at 9:50 PM, Ron Wheeler
> <rwheeler@artifact-software.com
> <ma...@artifact-software.com>> wrote:
>
> I am certainly not an expert in this area but it seems that you
> are getting a bit far into the details.
> CXF looks after a lot of the plumbing for you and you should be
> able to get a simple web service and its clients going without to
> much worry about the internal flow.
>
> What are you trying to build?
> Is there anything about what you need to do that you expect to be
> outside the normal web services pattern?
>
> We were able to build quite a few web services in a simple
> Tomcat/Jetspeed portal environment just by following the normal
> CXF patterns as described on the site and in the docs.
> I did not do the work but my team got things done very quickly
> with no big complaints or delays.
>
> It might help if you described your IDE and the frameworks that
> you want to use.
> For example, we used Eclipse/STS with a Spring, Hibernate, MySQL
> and Tomcat.
> This probably has an impact on the tools, process and packaging
> that people will recommend to you.
>
> Good luck.
> Ron
>
>
>
> On 15/03/2011 11:10 AM, Raj Floyd wrote:
>
> Hi Dan,
>
> Thanks for the reply. But still need to understand this. I am
> a novice in
> Web service and researching on various Web service use cases.
> The obvious
> and basic ones are consuming the service with the code first
> and contract
> first approach. Coming to your reply:
>
> 1. I can use the generated client and server code (and they do
> not use
> ObjectFactory or XXResponse classes) and comfortably run my
> services. Now as
> you said the ObjectFactory is checked by JAXB for xsd:any
> type. What
> situation makes use of this scenario?
>
> 2. XX and XXResponse are used as wrappers @ runtime. It
> happens when?
>
> I am sorry for the above questions, it may sound trivial, but
> need to
> understand the flow. Any pointers will be greatly appreciated.
>
> Thx
>
> Raj
>
> On Tue, Mar 15, 2011 at 7:18 PM, Daniel Kulp<dkulp@apache.org
> <ma...@apache.org>> wrote:
>
> On Tuesday 15 March 2011 8:27:40 AM Raj Floyd wrote:
>
> Hi,
>
> When I use wsdl2java with either client or server
> option, it generates
> ObjectFactory class,
>
> JAXB itself uses that. In cases where there are xsd:any
> and similar or
> places
> where a JAXBElement is needed, it checks the ObjectFactory
> for the right
> methods for dealing with the actual elements.
>
> XX and XXResponse classes. Why are these classes
> generated and where it could be useful?
>
> When available, they are used at runtime. The parameters
> (and returns) are
> wrappered with these objects and fed into JAXB as one
> whole unit instead of
> for each param.
>
> --
> Daniel Kulp
> dkulp@apache.org <ma...@apache.org>
> http://dankulp.com/blog
> Talend - http://www.talend.com
>
>
>
Re: wsdl2java: ObjectFactory
Posted by Raj Floyd <ra...@gmail.com>.
Thanks Ron.
I am specifically interested in CXF framework. Like I understand your point
but the only reason I am going into details is that I can understand the Web
service better as a product or a technology. There are several concepts like
JAXWS, JAXB, WSDL, Schemas....etc and each plays a significant role in the
Web service infrastructure per say. And there are plenty of Web service
based use cases which most of the people (specially ones like me) don't even
know.
I am just going a bit far as I can understand the semantics of this
framework (CXF) better and therefore also understand the Web service as a
technology better.
My apologies if that has confused you. I am just kinda researching and it
can just make me more better equipped to use Web services in projects.
Thx
Raj
On Tue, Mar 15, 2011 at 9:50 PM, Ron Wheeler <rwheeler@artifact-software.com
> wrote:
> I am certainly not an expert in this area but it seems that you are getting
> a bit far into the details.
> CXF looks after a lot of the plumbing for you and you should be able to get
> a simple web service and its clients going without to much worry about the
> internal flow.
>
> What are you trying to build?
> Is there anything about what you need to do that you expect to be outside
> the normal web services pattern?
>
> We were able to build quite a few web services in a simple Tomcat/Jetspeed
> portal environment just by following the normal CXF patterns as described on
> the site and in the docs.
> I did not do the work but my team got things done very quickly with no big
> complaints or delays.
>
> It might help if you described your IDE and the frameworks that you want to
> use.
> For example, we used Eclipse/STS with a Spring, Hibernate, MySQL and
> Tomcat.
> This probably has an impact on the tools, process and packaging that people
> will recommend to you.
>
> Good luck.
> Ron
>
>
>
> On 15/03/2011 11:10 AM, Raj Floyd wrote:
>
>> Hi Dan,
>>
>> Thanks for the reply. But still need to understand this. I am a novice in
>> Web service and researching on various Web service use cases. The obvious
>> and basic ones are consuming the service with the code first and contract
>> first approach. Coming to your reply:
>>
>> 1. I can use the generated client and server code (and they do not use
>> ObjectFactory or XXResponse classes) and comfortably run my services. Now
>> as
>> you said the ObjectFactory is checked by JAXB for xsd:any type. What
>> situation makes use of this scenario?
>>
>> 2. XX and XXResponse are used as wrappers @ runtime. It happens when?
>>
>> I am sorry for the above questions, it may sound trivial, but need to
>> understand the flow. Any pointers will be greatly appreciated.
>>
>> Thx
>>
>> Raj
>>
>> On Tue, Mar 15, 2011 at 7:18 PM, Daniel Kulp<dk...@apache.org> wrote:
>>
>> On Tuesday 15 March 2011 8:27:40 AM Raj Floyd wrote:
>>>
>>>> Hi,
>>>>
>>>> When I use wsdl2java with either client or server option, it generates
>>>> ObjectFactory class,
>>>>
>>> JAXB itself uses that. In cases where there are xsd:any and similar or
>>> places
>>> where a JAXBElement is needed, it checks the ObjectFactory for the right
>>> methods for dealing with the actual elements.
>>>
>>> XX and XXResponse classes. Why are these classes
>>>> generated and where it could be useful?
>>>>
>>> When available, they are used at runtime. The parameters (and returns)
>>> are
>>> wrappered with these objects and fed into JAXB as one whole unit instead
>>> of
>>> for each param.
>>>
>>> --
>>> Daniel Kulp
>>> dkulp@apache.org
>>> http://dankulp.com/blog
>>> Talend - http://www.talend.com
>>>
>>>
>
Re: wsdl2java: ObjectFactory
Posted by Ron Wheeler <rw...@artifact-software.com>.
I am certainly not an expert in this area but it seems that you are
getting a bit far into the details.
CXF looks after a lot of the plumbing for you and you should be able to
get a simple web service and its clients going without to much worry
about the internal flow.
What are you trying to build?
Is there anything about what you need to do that you expect to be
outside the normal web services pattern?
We were able to build quite a few web services in a simple
Tomcat/Jetspeed portal environment just by following the normal CXF
patterns as described on the site and in the docs.
I did not do the work but my team got things done very quickly with no
big complaints or delays.
It might help if you described your IDE and the frameworks that you want
to use.
For example, we used Eclipse/STS with a Spring, Hibernate, MySQL and Tomcat.
This probably has an impact on the tools, process and packaging that
people will recommend to you.
Good luck.
Ron
On 15/03/2011 11:10 AM, Raj Floyd wrote:
> Hi Dan,
>
> Thanks for the reply. But still need to understand this. I am a novice in
> Web service and researching on various Web service use cases. The obvious
> and basic ones are consuming the service with the code first and contract
> first approach. Coming to your reply:
>
> 1. I can use the generated client and server code (and they do not use
> ObjectFactory or XXResponse classes) and comfortably run my services. Now as
> you said the ObjectFactory is checked by JAXB for xsd:any type. What
> situation makes use of this scenario?
>
> 2. XX and XXResponse are used as wrappers @ runtime. It happens when?
>
> I am sorry for the above questions, it may sound trivial, but need to
> understand the flow. Any pointers will be greatly appreciated.
>
> Thx
>
> Raj
>
> On Tue, Mar 15, 2011 at 7:18 PM, Daniel Kulp<dk...@apache.org> wrote:
>
>> On Tuesday 15 March 2011 8:27:40 AM Raj Floyd wrote:
>>> Hi,
>>>
>>> When I use wsdl2java with either client or server option, it generates
>>> ObjectFactory class,
>> JAXB itself uses that. In cases where there are xsd:any and similar or
>> places
>> where a JAXBElement is needed, it checks the ObjectFactory for the right
>> methods for dealing with the actual elements.
>>
>>> XX and XXResponse classes. Why are these classes
>>> generated and where it could be useful?
>> When available, they are used at runtime. The parameters (and returns) are
>> wrappered with these objects and fed into JAXB as one whole unit instead of
>> for each param.
>>
>> --
>> Daniel Kulp
>> dkulp@apache.org
>> http://dankulp.com/blog
>> Talend - http://www.talend.com
>>
Re: wsdl2java: ObjectFactory
Posted by Raj Floyd <ra...@gmail.com>.
Thanks Dan. It indeed helped.
On Wed, Mar 16, 2011 at 12:30 AM, Daniel Kulp <dk...@apache.org> wrote:
> On Tuesday 15 March 2011 11:10:16 AM Raj Floyd wrote:
> > Hi Dan,
> >
> > Thanks for the reply. But still need to understand this. I am a novice in
> > Web service and researching on various Web service use cases. The obvious
> > and basic ones are consuming the service with the code first and contract
> > first approach. Coming to your reply:
> >
> > 1. I can use the generated client and server code (and they do not use
> > ObjectFactory or XXResponse classes) and comfortably run my services. Now
> > as you said the ObjectFactory is checked by JAXB for xsd:any type. What
> > situation makes use of this scenario?
>
> If you have a sequence or something in your schema that has an <xsd:any/>
> or
> <xsd:any maxOccurs="unbounded"/> or similar, the code that is generated for
> that would be an Object or List<Object>. At parse time, when jaxb gets
> to
> that point in the incoming XML, it will take the incoming element name and
> check the information on the ObjectFactory to determine the class and such
> to
> unparse. If it can find the right information, it will parse to the
> right
> JAXB class. If the ObjectFactory isn't there or if there isn't a matching
> element name, it just parsed to a DOM and that is placed in the list.
>
>
> > 2. XX and XXResponse are used as wrappers @ runtime. It happens when?
>
> Within CXF in the WrapperClassIn/OutInterceptors. Without the
> wrappers,
> we need to call into JAXB for each param and for each return. That
> involves
> a little extra overhead. Also, if the param has some of the JAXB
> annotations
> on it directly, we have to delve into JAXB proprietary API's for those to
> work, and in some cases, that doesn't even work. With the wrappers, the
> JAXB annotaions are on the fields properly and such so we can make a single
> call to JAXB and it pretty much "just works".
>
> Hope that helps!
> Dan
>
>
> > I am sorry for the above questions, it may sound trivial, but need to
> > understand the flow. Any pointers will be greatly appreciated.
> >
> > Thx
> >
> > Raj
> >
> > On Tue, Mar 15, 2011 at 7:18 PM, Daniel Kulp <dk...@apache.org> wrote:
> > > On Tuesday 15 March 2011 8:27:40 AM Raj Floyd wrote:
> > > > Hi,
> > > >
> > > > When I use wsdl2java with either client or server option, it
> generates
> > > > ObjectFactory class,
> > >
> > > JAXB itself uses that. In cases where there are xsd:any and similar or
> > > places
> > > where a JAXBElement is needed, it checks the ObjectFactory for the
> right
> > > methods for dealing with the actual elements.
> > >
> > > > XX and XXResponse classes. Why are these classes
> > > > generated and where it could be useful?
> > >
> > > When available, they are used at runtime. The parameters (and returns)
> > > are wrappered with these objects and fed into JAXB as one whole unit
> > > instead of for each param.
> > >
> > > --
> > > Daniel Kulp
> > > dkulp@apache.org
> > > http://dankulp.com/blog
> > > Talend - http://www.talend.com
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
> Talend - http://www.talend.com
>
Re: wsdl2java: ObjectFactory
Posted by Daniel Kulp <dk...@apache.org>.
On Tuesday 15 March 2011 11:10:16 AM Raj Floyd wrote:
> Hi Dan,
>
> Thanks for the reply. But still need to understand this. I am a novice in
> Web service and researching on various Web service use cases. The obvious
> and basic ones are consuming the service with the code first and contract
> first approach. Coming to your reply:
>
> 1. I can use the generated client and server code (and they do not use
> ObjectFactory or XXResponse classes) and comfortably run my services. Now
> as you said the ObjectFactory is checked by JAXB for xsd:any type. What
> situation makes use of this scenario?
If you have a sequence or something in your schema that has an <xsd:any/> or
<xsd:any maxOccurs="unbounded"/> or similar, the code that is generated for
that would be an Object or List<Object>. At parse time, when jaxb gets to
that point in the incoming XML, it will take the incoming element name and
check the information on the ObjectFactory to determine the class and such to
unparse. If it can find the right information, it will parse to the right
JAXB class. If the ObjectFactory isn't there or if there isn't a matching
element name, it just parsed to a DOM and that is placed in the list.
> 2. XX and XXResponse are used as wrappers @ runtime. It happens when?
Within CXF in the WrapperClassIn/OutInterceptors. Without the wrappers,
we need to call into JAXB for each param and for each return. That involves
a little extra overhead. Also, if the param has some of the JAXB annotations
on it directly, we have to delve into JAXB proprietary API's for those to
work, and in some cases, that doesn't even work. With the wrappers, the
JAXB annotaions are on the fields properly and such so we can make a single
call to JAXB and it pretty much "just works".
Hope that helps!
Dan
> I am sorry for the above questions, it may sound trivial, but need to
> understand the flow. Any pointers will be greatly appreciated.
>
> Thx
>
> Raj
>
> On Tue, Mar 15, 2011 at 7:18 PM, Daniel Kulp <dk...@apache.org> wrote:
> > On Tuesday 15 March 2011 8:27:40 AM Raj Floyd wrote:
> > > Hi,
> > >
> > > When I use wsdl2java with either client or server option, it generates
> > > ObjectFactory class,
> >
> > JAXB itself uses that. In cases where there are xsd:any and similar or
> > places
> > where a JAXBElement is needed, it checks the ObjectFactory for the right
> > methods for dealing with the actual elements.
> >
> > > XX and XXResponse classes. Why are these classes
> > > generated and where it could be useful?
> >
> > When available, they are used at runtime. The parameters (and returns)
> > are wrappered with these objects and fed into JAXB as one whole unit
> > instead of for each param.
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://dankulp.com/blog
> > Talend - http://www.talend.com
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com
Re: wsdl2java: ObjectFactory
Posted by Raj Floyd <ra...@gmail.com>.
Hi Dan,
Thanks for the reply. But still need to understand this. I am a novice in
Web service and researching on various Web service use cases. The obvious
and basic ones are consuming the service with the code first and contract
first approach. Coming to your reply:
1. I can use the generated client and server code (and they do not use
ObjectFactory or XXResponse classes) and comfortably run my services. Now as
you said the ObjectFactory is checked by JAXB for xsd:any type. What
situation makes use of this scenario?
2. XX and XXResponse are used as wrappers @ runtime. It happens when?
I am sorry for the above questions, it may sound trivial, but need to
understand the flow. Any pointers will be greatly appreciated.
Thx
Raj
On Tue, Mar 15, 2011 at 7:18 PM, Daniel Kulp <dk...@apache.org> wrote:
> On Tuesday 15 March 2011 8:27:40 AM Raj Floyd wrote:
> > Hi,
> >
> > When I use wsdl2java with either client or server option, it generates
> > ObjectFactory class,
>
> JAXB itself uses that. In cases where there are xsd:any and similar or
> places
> where a JAXBElement is needed, it checks the ObjectFactory for the right
> methods for dealing with the actual elements.
>
> > XX and XXResponse classes. Why are these classes
> > generated and where it could be useful?
>
> When available, they are used at runtime. The parameters (and returns) are
> wrappered with these objects and fed into JAXB as one whole unit instead of
> for each param.
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
> Talend - http://www.talend.com
>
Re: wsdl2java: ObjectFactory
Posted by Daniel Kulp <dk...@apache.org>.
On Tuesday 15 March 2011 8:27:40 AM Raj Floyd wrote:
> Hi,
>
> When I use wsdl2java with either client or server option, it generates
> ObjectFactory class,
JAXB itself uses that. In cases where there are xsd:any and similar or places
where a JAXBElement is needed, it checks the ObjectFactory for the right
methods for dealing with the actual elements.
> XX and XXResponse classes. Why are these classes
> generated and where it could be useful?
When available, they are used at runtime. The parameters (and returns) are
wrappered with these objects and fed into JAXB as one whole unit instead of
for each param.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com