How to prevent the creation of a JAXBElement <String> in the CXF web service client?

I am trying to create a web service client using CXF in order to use the WCF web service. When I use wsdl2java, it generates objects with JAXBElement types instead of String.

I read about using the jaxb bindings.xml file to set generateElementProperty = "false" to try to fix the problem, but the web service I consume contains 7 imported schemas.

How can I specify generateElementProperty="false" on all seven schemes, or is there a way to apply it to all schemes?

+47
java web-services wcf jaxb cxf
Dec 10 2018-10-12
source share
2 answers

You need to create a binding file as shown below, it will be 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> 
+65
Jan 03 2018-11-11T00:
source share

Please note that in my case, I had to use <xjc:simple in my jaxb binding file to get rid of JAXBElement requests and responses in @Endpoint :

 <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" elementFormDefault="qualified" attributeFormDefault="unqualified" jaxb:extensionBindingPrefixes="xjc" jaxb:version="2.1"> <xs:annotation> <xs:appinfo> <jaxb:globalBindings> <xjc:simple /><!-- it did only work after adding this --> </jaxb:globalBindings> </xs:appinfo> </xs:annotation> </xs:schema> 
0
Jun 13 '19 at 7:02
source share



All Articles