Note that there are some explanatory texts on larger screens.

plurals
  1. POJAXB generating JAXBElement<String> instead of String
    text
    copied!<p>I am using <code>Apache CXF</code> <code>cxf-codegen-plugin</code> <code>Maven</code> plugin to generate sources from <code>WSDL</code> file. Problem is that I get <code>JAXBElement&lt;String&gt;</code> generated instead of <code>String</code>. I have added the <code>jaxb-bindings.xml</code> file which looks like this:</p> <pre class="lang-xml prettyprint-override"><code>&lt;jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"&gt; &lt;jaxb:globalBindings generateElementProperty="false"/&gt; &lt;/jaxb:bindings&gt; </code></pre> <p>This should prevent <code>JAXB</code> to generate <code>JAXBElement&lt;String&gt;</code>. But it is not working I still have <code>JAXBElement&lt;String&gt;</code> generated instead of <code>String</code>.</p> <p>My <code>Maven</code> plugin looks like this:</p> <pre class="lang-xml prettyprint-override"><code>&lt;plugin&gt; &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt; &lt;artifactId&gt;cxf-codegen-plugin&lt;/artifactId&gt; &lt;version&gt;${cxf.runtime.version}&lt;/version&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt; &lt;artifactId&gt;cxf-rt-bindings-soap&lt;/artifactId&gt; &lt;version&gt;${cxf.runtime.version}&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;generate-jaxb&lt;/id&gt; &lt;phase&gt;generate-sources&lt;/phase&gt; &lt;configuration&gt; &lt;additionalJvmArgs&gt;-Dfile.encoding=UTF8&lt;/additionalJvmArgs&gt; &lt;wsdlOptions&gt; &lt;wsdlOption&gt; &lt;wsdl&gt;src/main/resources/wsdl/Cubiks.wsdl&lt;/wsdl&gt; &lt;extraargs&gt; &lt;extraarg&gt;-b&lt;/extraarg&gt; &lt;extraarg&gt;${basedir}/jaxb-bindings.xml&lt;/extraarg&gt; &lt;extraarg&gt;-b&lt;/extraarg&gt; &lt;extraarg&gt;${basedir}/jaxws-bindings.xml&lt;/extraarg&gt; &lt;extraarg&gt;-exsh&lt;/extraarg&gt; &lt;extraarg&gt;true&lt;/extraarg&gt; &lt;extraarg&gt;-wsdlLocation&lt;/extraarg&gt; &lt;extraarg&gt;&lt;/extraarg&gt; &lt;/extraargs&gt; &lt;/wsdlOption&gt; &lt;wsdlOption&gt; &lt;wsdl&gt;src/main/resources/wsdl/CubiksCallBackService.wsdl&lt;/wsdl&gt; &lt;extraargs&gt; &lt;extraarg&gt;-b&lt;/extraarg&gt; &lt;extraarg&gt;${basedir}/jaxws-bindings.xml&lt;/extraarg&gt; &lt;extraarg&gt;-b&lt;/extraarg&gt; &lt;extraarg&gt;${basedir}/jaxb-bindings.xml&lt;/extraarg&gt; &lt;extraarg&gt;-exsh&lt;/extraarg&gt; &lt;extraarg&gt;true&lt;/extraarg&gt; &lt;extraarg&gt;-p&lt;/extraarg&gt; &lt;extraarg&gt;com.cubiks.ws.callback&lt;/extraarg&gt; &lt;extraarg&gt;-wsdlLocation&lt;/extraarg&gt; &lt;extraarg&gt;&lt;/extraarg&gt; &lt;/extraargs&gt; &lt;/wsdlOption&gt; &lt;/wsdlOptions&gt; &lt;/configuration&gt; &lt;goals&gt; &lt;goal&gt;wsdl2java&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre> <p><code>CXF</code> version is <code>2.6.0</code>. Does someone know where might be the problem?</p> <p><strong>EDIT</strong></p> <p>The XSD is very huge. This is the element which generating <code>JAXBElement&lt;String&gt;</code></p> <pre><code> &lt;xs:complexType name="ServiceResponse"&gt; &lt;xs:sequence&gt; &lt;xs:element minOccurs="0" name="RequestStatus" type="tns:RequestStatus"/&gt; &lt;xs:element minOccurs="0" name="RequestStatusDescription" nillable="true" type="xs:string"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;xs:element name="ServiceResponse" nillable="true" type="tns:ServiceResponse"/&gt; </code></pre> <p>And the generated source is:</p> <pre><code>@XmlElementRef(name = "RequestStatusDescription", namespace = "http://www.cubiksonline.com/2009/08/AssessmentProvider", type = JAXBElement.class) protected JAXBElement&lt;String&gt; requestStatusDescription; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload