Hi there,
I tried to implement a webservice which returns a String of my int Array, but it does not work. The following error will appear:
Error-Message:
SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
Web-Service
public String setInts(IntArray intAry) {
return intAry.toString();
}
I put the Array in a wrapper-class as described in the Wiki
http://wiki.jboss.org/wiki/Wiki.jsp?page=WSArrayTypeMapping. I hope that this works for int-Arrays like for custom types.
IntArray-class
public class IntArray {
private int[] intArray;
public int[] getIntArray() {
return intArray;
}
public void setIntArray(int[] intArray) {
this.intArray = intArray;
}
}
ws4ee-deployment.xml
<typeMapping
qname='ns1:IntArray'
xmlns:ns1='http://types.zoo.ams'
type='java:interfaces.IntArray'
serializer='org.jboss.axis.encoding.ser.BeanSerializerFactory'
deserializer='org.jboss.axis.encoding.ser.BeanDeserializerFactory'
encodingStyle=''>
</typeMapping>
<typeMapping
qname='ns1:IntArrayResponse'
xmlns:ns1='http://types.zoo.ams'
type='java:interfaces.IntArray'
serializer='org.jboss.axis.encoding.ser.BeanSerializerFactory'
deserializer='org.jboss.axis.encoding.ser.BeanDeserializerFactory'
encodingStyle=''>
</typeMapping>
After creating a client for this Webservice there are two new class-files:
ArrayOf_xsd_int.java and
IntArray.java
Client-code
int[] intAry = {1,2,3,4,5};
ArrayOf_xsd_int xsdIntAry = new ArrayOf_xsd_int();
IntArray intArray = new IntArray();
xsdIntAry.setItem(intAry);
intArray.setIntArray(xsdIntAry);
System.out.println("setInts: " + endpoint.setInts(intArray));
First question of two, for what is the ArrayOf_xsd_int?
Second, why does my webservice not work?
Thanks in advance for your help!