We have a POJO web service implemented in AXIS2 v1.5.2 running in Tomcat 6 behind Apache2 webserver.
For demonstration purposes, I will focus on the validateUser message and corresponding method. All of the messages are behaving in a similar fashion.
I have seen this as well as a couple of other related questions but they do not seem to get to the bottom of the issue.
When requests are sent to the service, the parameters are being passed to the POJA as null and blank.
First the WSDL:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://service.icomet.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax21="http://util.java/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://service.icomet.com">
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://util.java/xsd">
<xs:complexType name="Map">
<xs:sequence>
<xs:element minOccurs="0" name="empty" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:ax22="http://util.java/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.icomet.com">
<xs:import namespace="http://util.java/xsd"/>
<xs:element name="validateUser">
<xs:complexType>
<xs:sequence>
<xs:element name="user" nillable="true" type="xs:string"/>
<xs:element name="userPassword" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="validateUserRequest">
<wsdl:part name="parameters" element="ns:validateUser"/>
</wsdl:message>
After following along in the code of org.apache.axis2.rpc.receivers.RPCMessageReceiver, org.apache.axis2.rpc.receivers.RPCUtil and org.apache.axis2.databinding.utils.BeanUtil what I see is the service getting my request with the params intact. The OMElement printed in the log from:
BeanUtil.deserialize(OMElement response, Object[] javaTypes, ObjectSupplier objectSupplier) looks like this: deserialize(OMElement response, Object[] javaTypes, ObjectSupplier objectSupplier)
looks like this:
<SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<ns:validateUser xmlns:ns="http://service.icomet.com">
<ns:user>test</ns:user>
<ns:userPassword>values</ns:userPassword>
</ns:validateUser>
After a call to get the children of the OMElement and looking at the first child of the above OMElement I see this:
<ns:validateUser xmlns:ns="http://service.icomet.com">
<ns:user>test</ns:user>
<ns:userPassword>values</ns:userPassword>
</ns:validateUser>
Calling getText() on the above OMElement returns multiple blank lines in the log.
I added the following method:
private static void showElement(OMElement omElement) {
System.out.println("onElement class:" + omElement.getClass().getName());
System.out.println("omElement:" + omElement);
System.out.println("omElement.getText:" + omElement.getText());
for (Iterator it = omElement.getChildElements(); it.hasNext();) {
Object object = it.next();
System.out.println("child class name:" + object.getClass().getName());
System.out.println("child to string:" + object);
}
for (Iterator it = omElement.getAllAttributes(); it.hasNext();) {
OMAttribute object = (OMAttribute) it.next();
System.out.println("OMAttribute:" + object.getAttributeValue());
}
}
to the BeanUtil class to have better look at this OMElement. This code returns the following:
onElement class:org.apache.axiom.om.impl.llom.OMElementImpl
omElement:<ns:validateUser xmlns:ns="http://service.icomet.com">
<ns:user>test</ns:user>
<ns:userPassword>values</ns:userPassword>
</ns:validateUser
omElement.getText:
child class name:org.apache.axiom.om.impl.llom.OMElementImpl
child to string:<ns:user xmlns:ns="http://service.icomet.com">test</ns:user>
child class name:org.apache.axiom.om.impl.llom.OMElementImpl
child to string:<ns:userPassword xmlns:ns="http://service.icomet.com">values</ns:userPassword>
So, I am seeing the values. They are arriving and getting in the door so to speak. However, due to the fact that org.apache.axis2.databinding.typemapping.SimpleTypeMapper.getSimpleTypeObject calls getText on the OMElement and returns an empty string, the RPCUtil.processRequest method is returning an object array with an empty str开发者_StackOverflow社区ing and a null object and this gets passed on to the POJO.
I know its a long question, but I figured I might as well add all this info up front.
Turns out to be a bug in AXIS2 1.5.
Some of the details to be found here
Defect was addressed in nightly build on 1/6/2011. Still waiting for confirmation as to what exactly was done to fix the issue. There were a couple of solutions discussed in the thread.
I used the most obvious answer for the moment and patched the code myself.
精彩评论