I have a WSDL file which is from an Axis2 Web Service. When I generate a client stub using wsimport
given the WSDL file, the resulting classes require JAXBElement
paramaters. Why is it like that?
Sample Method from one of the Generated Classes:
JAXBElement<DataBean> value;
public void setValue(JAXBElement<DataBean> value)
{
this.value = ((JAXBElement<DataBean>) value);
}
I am expecting it to look like this (without the JAXBElement):
DataBean value;
public void setValue(DataBean value)
{
this.value= (DataBean) value;
}
The tutorials I saw on the net does not set the classes to JAXBElement. What could be the problem? Please take note that the server is an Axis2 web service and the WSDL file is auto-generated by Axis2. The assumption is I have no control over the server.
How can I make it in such a way that wsimport
won't convert the parameters to JAXBElements?
Below is an excerpt from the WSDL file: (I ignored some of the tags to include only the essential tags)
<xs:element name="getData">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="getData" nillable="true" type="ax220:getData"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="getData">
<xs:sequence>
<xs:element minOccurs="0" name="value" nillable="true" type="ax219:DataBean"/>
</xs:sequence>
</xs:complexType>
<wsdl:message name="getDataRequest">
<wsdl:part name="parameters" element="ns:getData"/>
</wsdl:message>
<wsdl:message name="getDataResponse">
<wsdl:part name="parameters" element="ns:getDataResponse"/>
</wsdl:message>
<wsdl:operation name="getData">
<wsdl:input message="ns:getDataRequest" wsaw:Action="urn:getData"/>
<wsdl:output message="ns:getDataResponse" wsaw:Action="urn:getDataResponse"/>
</wsdl:operation>
<wsdl:operation name="getData">
<soap:operation soapAction="urn:getData" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getData">
<soap12:operation soapAction="urn:getData" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getData">
<http:operation location="getData"/>
<wsdl:input>
<mime:content type="text/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
As read on this page :
http://www.techdevtips.com/java/java-webservice-client-how-to-remove-jaxbelement
use a data binding file with this code :
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
xmlns:xjc= "http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc">
<jaxb:globalBindings generateElementProperty="false">
<xjc:simple />
</jaxb:globalBindings>
</jaxb:bindings>
and use it in your wsimport ant task by filling the binding attribute (or -b flag argument if you use the runnable)
Cheers :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With