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.
Related
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
Firstly, I'd like to know how to find this out for myself next time. If not, then can somebody tell me?
The reason I want to know is because I want to use the #JsonIdentityInfo annotation on my Cloud Endpoints entities to deal with recursive serialization, but it doesn't compile. I guess this would mean it's some Jackson version less than 2.0.
You should not use repackaged libs - they are for internal GAE use only. They are not part of official API and can change at any time.
Include your own Jackson jar in your project.
Like Peter says, include your own Jackson jar. Make your code use this Jackson library. GAE will use their repackaged JSON parser or whatever they change it to (even not necessarily Jackson). That is of no concern to your project. GAE has no reason to look for Jackson annotations on your Entity classes - only your source code should tell only your Jackson jar to do that.
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.
'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
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/