Hello,
The @XmlJavaTypeAdapter I wrote doens't seem to be called by the server.
I have a FinalService service that returns an object that holds a String[].
I want the adapter to transform it into an Integer[].
Details:
----------------------- THE WEB SERVICE ----------------------------
@WebService(name = "FinalService",
serviceName = "FinalService",
portName = "FinalServicePort",
targetNamespace="
http://FinalService/")
@BindingType(SOAPBinding.SOAP11HTTP_BINDING)
public class FinalService {
@WebMethod
public TestResult bar(@WebParam(name = "num") int arg) {
TestResult result = new TestResult();
result.someList = new String[] {"1", "2"};
return result;
}
}
----------------------- THE WEB SERVICE ----------------------------
----------------------- THE POJO ----------------------------
@XmlRootElement(namespace = "
http://FinalService/")
public class TestResult {
@XmlElement(name = "someList", namespace = "
http://FinalService/")
@XmlJavaTypeAdapter(service.helper.IntegerStringAdapter.class)
public String[] someList;
}
----------------------- THE POJO ----------------------------
----------------------- THE ADAPTER ----------------------------
public class IntegerStringAdapter extends XmlAdapter<Integer[], String[]> {
@Override
public Integer[] marshal(String[] arg) throws Exception {
Integer[] returnedArray = new Integer[arg.length];
for (int i = 0; i < arg.length; i++) {
returnedArray[i] = Integer.parseInt(arg[i]);
}
return returnedArray;
}
@Override
public String[] unmarshal(Integer[] arg) throws Exception {
String[] returnedArray = new String[arg.length];
for (int i = 0; i < arg.length; i++) {
returnedArray[i] = Integer.toString(arg[i]);
}
return returnedArray;
}
}
----------------------- THE ADAPTER ----------------------------
Environment details:
- JAX-WS 2.1.2
- JAXB 2.1.9
- Axis2 1.4.1
- Tomcat 6.0.18
- Eclipse3.4
----------------------- THE SCHEMA ----------------------------
<xs:element name="bar" type="tns:bar"/>
<xs:element name="barResponse" type="tns:barResponse"/>
<xs:element name="testResult" type="tns:testResult"/>
<xs:complexType name="bar">
<xs:sequence>
<xs:element name="num" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="barResponse">
<xs:sequence>
<xs:element name="return" type="tns:testResult" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="testResult">
<xs:sequence>
<xs:element name="someList" type="xs:int" form="qualified"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
----------------------- THE SCHEMA ----------------------------
----------------------- services.xml ----------------------------
<service name="FinalService">
<Description> Test Service </Description>
<messageReceivers>
<messageReceiver mep="
http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
<messageReceiver mep="
http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</messageReceivers>
<parameter name="ServiceClass"
locked="false">service.FinalService</parameter>
</service>
----------------------- services.xml ----------------------------
----------------------- SOAP RESPONSE ----------------------------
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope
xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:barResponse xmlns:ns="
http://FinalService/">
<ns:return xmlns:ax21="
http://service/xsd"
type="service.TestResult" />
</ns:barResponse>
</soapenv:Body>
</soapenv:Envelope>
----------------------- SOAP RESPONSE ----------------------------
I use the aar mechanism for deployment.
One thing that's worth mentioning is that I got ClassNotFoundExceptions at
first on classes from javax.xml.bind.annotation (where @XmlJavaTypeAdapter
resides).
I saw that this classes come from the jaxb-api.jar.
I didn't have such a jar in my classpath (not in my application nor in
axis2).
I wondered how come these classes are not part of axis2-jaxb-SNAPSHOT.jar.
But apparently they're not, and I had to add the jaxb-api.jar to my
application.
To sum the problem up - the adapter is not called, and I get a response with
nothing in it (whereas an integer[] should be inside the response, as you
can understand from my service implementation).
I hope it's comprehensible...
Many thanks in advance,
Daniel
--
View this message in context: http://www.nabble.com/%40XmlJavaTypeAdapter-not-called-tp20602488p20602488.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.