You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by boekhold <bo...@gmail.com> on 2011/03/22 10:07:22 UTC

Generate JAX-WS bindings from existing Web Services, problems with schemas

Hi all,

I'm working with a product that offers multiple Web Services (around 180 in
fact) that have been developed with CXF. My requirement is to geenrate
JAX-WS bindings for a subset of those 180 services.

The WSDL for each of the services embeds 3 schemas with the following
targetnamespaces:
- XXXService
- com.company.product.data
- com.company.product.exceptions

When I retrieve the WSDL for each service using
http://182.168.1.1:8080/WebServices/XXXService?wsdl, the schema parts for
the "data" and "exceptions" schemas only contain those elements/types that
are actually used by the specific service. So each WSDL contains only a
sub-set of the "total schema".

I'm currently having trouble when I need to create bindings for multiple
services. Example:

wsdl2java -frontend jaxws21 XXXService.wsdl
wsdl2java -frontend jaxws21 YYYService.wsdl

Both runs will generate JAXB bindings for the elements inside the 3 schema
parts. But the second run *overwrites* the ObjectFactory class inside the
data and exceptions packages, which means that when I generate the bindings
for YYYService, I lose the factory methods for those elements that are only
used by the XXXService but not by the YYYService.

I could of course just use "-p
http://data.product.company.com=com.company.product.xxxservice" to generate
separate copies of these jaxb bindings for each service, but that will
result in a massive duplication of code/classes when I need to do this for a
number of services. I don't like duplicate code.

These web services are provided by a *product*, and I do not have access to
the code of that product. So my only option is to solve this on my side, I
don't have the luxury of being able to modify the services or use the source
code of the product.

Is there any way to generate JAX-WS bindings for these services so that I do
not end up with duplicate code/classes for the 2 data and exceptions
namespaces?

Kind regards, Maarten

--
View this message in context: http://cxf.547215.n5.nabble.com/Generate-JAX-WS-bindings-from-existing-Web-Services-problems-with-schemas-tp4250617p4250617.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Generate JAX-WS bindings from existing Web Services, problems with schemas

Posted by Daniel Kulp <dk...@apache.org>.

The only way I can think of to do this is to somehow create a  set of 
"complete" schemas that would include ALL the types from all the services.    
You would likely need to grab all the schemas and merge them together 
manually.   Not fun.  

From there, you can use xjc to generate the types from the schema.  That would 
generate the big ObjectFactory that would be complete.    

For wsdl2java, you can then add a binding file that turns off the mapping of 
the types for those schemas.     With 2.3.4/2.4, we've added a -noTypes flag 
to wsdl2java that would do that automatically.

Dan


On Tuesday 22 March 2011 5:07:22 AM boekhold wrote:
> Hi all,
> 
> I'm working with a product that offers multiple Web Services (around 180 in
> fact) that have been developed with CXF. My requirement is to geenrate
> JAX-WS bindings for a subset of those 180 services.
> 
> The WSDL for each of the services embeds 3 schemas with the following
> targetnamespaces:
> - XXXService
> - com.company.product.data
> - com.company.product.exceptions
> 
> When I retrieve the WSDL for each service using
> http://182.168.1.1:8080/WebServices/XXXService?wsdl, the schema parts for
> the "data" and "exceptions" schemas only contain those elements/types that
> are actually used by the specific service. So each WSDL contains only a
> sub-set of the "total schema".
> 
> I'm currently having trouble when I need to create bindings for multiple
> services. Example:
> 
> wsdl2java -frontend jaxws21 XXXService.wsdl
> wsdl2java -frontend jaxws21 YYYService.wsdl
> 
> Both runs will generate JAXB bindings for the elements inside the 3 schema
> parts. But the second run *overwrites* the ObjectFactory class inside the
> data and exceptions packages, which means that when I generate the bindings
> for YYYService, I lose the factory methods for those elements that are only
> used by the XXXService but not by the YYYService.
> 
> I could of course just use "-p
> http://data.product.company.com=com.company.product.xxxservice" to generate
> separate copies of these jaxb bindings for each service, but that will
> result in a massive duplication of code/classes when I need to do this for
> a number of services. I don't like duplicate code.
> 
> These web services are provided by a *product*, and I do not have access to
> the code of that product. So my only option is to solve this on my side, I
> don't have the luxury of being able to modify the services or use the
> source code of the product.
> 
> Is there any way to generate JAX-WS bindings for these services so that I
> do not end up with duplicate code/classes for the 2 data and exceptions
> namespaces?
> 
> Kind regards, Maarten
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Generate-JAX-WS-bindings-from-existing-Web
> -Services-problems-with-schemas-tp4250617p4250617.html Sent from the
> cxf-user mailing list archive at Nabble.com.

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com