JAXB generating JAXBElement instead of String

What I had to do is to wrap jaxb:globalBindings with another jaxb:bindings. <jaxb:bindings version=”2.0″ xmlns:jaxb=”http://java.sun.com/xml/ns/jaxb”> <jaxb:bindings> <jaxb:globalBindings generateElementProperty=”false”/> </jaxb:bindings> </jaxb:bindings> Now everything is working, there is no JAXBElement<String> generated anymore.

How to return a partial JSON response using Java?

If you use Jackson (a great JSON lib – kind of the standard for Java I believe), you may use the @View annotation to filter what you want in the resulting object. I understand that you want something dynamic so it’s a bit more complicated. You will find what you are looking for here: http://www.cowtowncoder.com/blog/archives/2011/02/entry_443.html … Read more

How can I pass complex objects as arguments to a RESTful service?

After digging a bit I quickly found out there are basically two options: Option 1 You pass a “wrapper object” containing all the other parameters to the service. You might need to annotate this wrapper class with JAXB annotations like @XmlRootElement in order for this to work with the Jettison based provider, but if you … Read more

How do I prevent JAXBElement from being generated in a CXF Web Service client?

You have to create a binding file as below, this will get applied globally and use it as wsdl2java – b “bindings.txt” “wsdl” <jaxb:bindings version=”2.1″ xmlns:jaxb=”http://java.sun.com/xml/ns/jaxb” xmlns:xjc=”http://java.sun.com/xml/ns/jaxb/xjc” xmlns:xs=”http://www.w3.org/2001/XMLSchema”> <jaxb:globalBindings generateElementProperty=”false”/> </jaxb:bindings>

How to log Apache CXF Soap Request and Soap Response using Log4j?

You need to create a file named org.apache.cxf.Logger (that is: org.apache.cxf file with Logger extension) under /META-INF/cxf/ with the following contents: org.apache.cxf.common.logging.Log4jLogger Reference: Using Log4j Instead of java.util.logging. Also if you replace standard: <cxf:bus> <cxf:features> <cxf:logging/> </cxf:features> </cxf:bus> with much more verbose: <bean id=”abstractLoggingInterceptor” abstract=”true”> <property name=”prettyLogging” value=”true”/> </bean> <bean id=”loggingInInterceptor” class=”org.apache.cxf.interceptor.LoggingInInterceptor” parent=”abstractLoggingInterceptor”/> <bean id=”loggingOutInterceptor” … Read more