How WSDLToJava in cxf works? - cxf

'org.apache.cxf.tools.wsdlto.WSDLToJava' converts wsdl to java classes.
Is it using JAXB internally?How come this command is able to generate classes like how 'xjc' creates?Can somebody explain me how it works?

CXF uses xjc internally for code generation.
Refer to following for more information (from CXF official page)
In CXF versions prior to 2.3.0, the xjc plugins were shaded directly into the big cxf bundle jar. In 2.3.0, they were removed from the jar and are placed individually into the lib directory of the distribution. The xjc plugins are only code generation utilities and not used at all at runtime which is why they were pulled out.
The Apache CXF XJC-Utils subproject provides a bunch of utilities for working with JAXB to generate better or more usable code.
Currently, it consists of the following modules:
cxf-xjc-plugin Provides a maven wrapper around the JAXB XJC utility
cxf-xjc-dv Initialize fields mapped from elements/attributes with their default values
cxf-xjc-ts Implements the toString() method
cxf-xjc-boolean Generate getters named getXXX() for Booleans instead of isXXX()
cxf-xjc-wsdlextension Adds extensions methods to allow generated beans to be used as WSDL4J extensors
cxf-xjc-bug671 Provides a workaround for https://jaxb.dev.java.net/issues/show_bug.cgi?id=671
- Not needed for JAXB >=2.1.12

WSDL2Java is a command line tool that generates Java classes from an existing WSDL document. Generated classes represent client stubs, server skeletons and data types that will helps you to write client side and server Java programs for Web services defined in the WSDL document.
DEFAULT_FRONTEND_NAME = "jaxws";
DEFAULT_DATABINDING_NAME = "jaxb";
For details,
http://cxf.apache.org/docs/wsdl-to-java.html http://grepcode.com/file/repo1.maven.org/maven2/org.apache.cxf/cxf-bundle/2.0.6/org/apache/cxf/tools/wsdlto/WSDLToJava.java

Related

Programmatically getting Apache Camel components operations, parameters, options decriptions

Is there a way to get any Apache Camel component "metadata" using Java code, like the list of options and other parameters and their types? I think some automatic help builder was mentioned somewhere that might be of use for this task without using reflection.
A way to get the registered components of all types (including data formats and languages) with java code is also sought. Thanks
Yeah take a look at the camel-catalog JAR which includes all such details. This JAR is what the tooling uses such as some of the Maven tooling itself, or IDE plugs for IntelliJ or Eclipse etc. The JAR has both Java API and metadata files embedded in the JAR you can load.
At runtime you can also access this catalog via RuntimeCamelCatalog which you can access via CamelContext. The runtime catalog is a little bit more limited than CamelCatalog as it has a view of what actually is available at runtime in the current Camel application.
Also I cover this in my book Camel in Action 2nd edition where there is a full chapter devoted on Camel tooling and how to build custom tooling etc.
This is what I've found so far
http://camel.apache.org/componentconfiguration.html

XSD Restrictions for bottom-up JAX-WS

We are using Spring and CXF to provide SOAP Web Services. The WSDL is being generated from Java Code.
Is there a way to define validation rules in Java code that would be applied to generated XSD?
For example, support for some of JSR 303 annotations would be great. In such case this code:
#Pattern(regexp = "[0-9]+/[0-9]+")
private String phone;
would evaluate to such XSD:
<restriction base="string">
<pattern value="[0-9]+/[0-9]+"></pattern>
</restriction>
I was looking for such JAXB extension: https://github.com/whummer/jaxb-facets
Unfortunately, it's not an extension to JAXB but a fork, so it completely replaces JAXB implementation from JDK.
The intention of this project was to be integrated into JDK, but it did not happen as you can see in this ticket: https://github.com/javaee/jaxb-v2/issues/917
There is also another project addressing a similar issue: https://github.com/krasa/krasa-jaxb-tools, but this one is also not supported anymore.

Is there tool similar to CXF wsdl2java can generate client code for aegis?

CXF wsdl2java tool can generate client code which databinding is jaxb. It seems wsdl2java can not generate aegis code. Is there a similar tool can generate client code for aegis?
No. Aegis is designed as a purely "java first" databinding as it cannot handle a lot of various schema concepts and such. If starting from WSDL, JAXB is strongly encouraged.

Spring AOP - exclude specific aspects?

I'm using Spring 3.0.5, and was wondering if it's possible, to somehow exclude aspect classes from being loaded that have been annotated with the #Aspect stereotype, but at the same time, include other aspect annotated classes? It seems to be an all or nothing if you're going the annotation route(which I am) I've tried looking at the and but can;t seem to find anything that hints at this.
The reason for this is that I have a central core library which contains aspects, but I may not want to include these aspects in every project I create using this central library.
Thanks.
This is a long time for an answer...
If you are using AspectJ annotations with Spring AOP and not AspectJ runtime or compile-time weaving then you're in luck. Spring will only pick up #Aspect annotated classes if they're annotated with something like #Component as well. Spring does not consider #Aspect a candidate for component scanning. If you're using XML configuration, simply remove that bean from your config.
I would suggest NOT using component scanning that would hit a core library. For example, if your app is com.example.myapp1 and your core library is com.example.corelibrary.* make sure your component scanning is looking at com.example.myapp1 ONLY and not com.example.
It is not safe to component scan outside of your app's base package because of this exact reason. Pull in the individual aspects with an XML config for the bean.

JAXB Naming Collision Salesforce Integration

I'm attempting to integrate with Salesforce using MyEclipse. The wizard fails because of a naming collision on a complex type "DescribeLayout". I need to write a JAXB binding file to ensure that the two interfaces that are created by the xjc compiler are in different packages, but I have absolutely no idea how to do this.
I do not have the URI's to the schemas that make up the WSDL, only the URN's.
This blog post shows how to append a suffix to type names to avoid this. I'm not a JAXB expert, but presumably there is a way to configure it to use a different package instead of a suffix.
http://blog.teamlazerbeez.com/2009/05/23/salesforcecom-partner-soap-api-jax-ws-tutorial-part-1/

Resources