Given:
import org.apache.axis.client.* ;
import org.apache.axis.encoding.* ;
import javax.xml.rpc.ParameterMode ;
import javax.xml.rpc.ParameterMode ;
import javax.xml.namespace.QName ;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
public class a {
public class foo {
public String x ;
public String getX() { return x ; };
public void setX(String xx) { x = xx ; }
}
void run() throws Exception {
QName qn = new QName("a", "foo");
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress("http://localhost:81/axis/services/echo");
call.addParameter( new QName("foo", "name"), qn,
foo.class, ParameterMode.IN );
call.setReturnType(XMLType.XSD_STRING);
call.registerTypeMapping(foo.class, qn,
new BeanSerializerFactory(foo.class,qn),
new BeanDeserializerFactory(foo.class,qn));
call.invoke("callIt", new Object[] {new foo()} );
}
static void main(String[] args) throws Exception {
(new a()).run();
}
}
It produces a soap-env with a body of:
<soapenv:Body>
<callIt>
<ns1:name href=""#id0"" xmlns:ns1="foo"/>
</callIt>
<multiRef id="id0" SOAP-ENC:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:foo" xmlns:ns2="a">
<x xsi:nil="true"/>
</multiRef>
</soapenv:Body>
Notice the "x" element doesn't have an xsi:type attribute. If I changed it so that it wasn't a complex type, but rather something like a String then it does show the xsi:type - which I do believe is the correct behavior.
I've attached a fix for this but I'd like someone who "really" understand the serializer code better to look at it first and commit if for me.
thanks,
-Dug
(See attached file: BeanDeserializer.java)
Diff:
Index: java/src/org/apache/axis/encoding/ser/BeanSerializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerialize
r.java,v
retrieving revision 1.38
diff -u -r1.38 BeanSerializer.java
--- java/src/org/apache/axis/encoding/ser/BeanSerializer.java 1 Jul 2002 16:09
:39 -0000 1.38
+++ java/src/org/apache/axis/encoding/ser/BeanSerializer.java 1 Jul 2002 16:26
:48 -0000
@@ -192,7 +192,11 @@
? baseJavaType : propValue.getClass();
context.serialize(qname,
null,
- propValue, javaType);
+ propValue,
+ javaType,
+ context.getQNameForClass(javaType),
+ true,
+ true);
} else {
// Collection of properties: serialize each one
int j=0;
BeanDeserializer.java
Description: Binary data