Okay finally figured this out. It turns out in addition to
registering a serialized facotry ofr the array
call.registerTypeMapping(int.class, new
QName("http://www.w3.org/2001/XMLSchema", "int"),
ArraySerializerFactory.class,
ArrayDeserializerFactory.class);
You also need to register a serializer factory for int.
call.registerTypeMapping(int.class, new
QName("http://www.w3.org/2001/XMLSchema", "int"),
SimpleSerializerFactory.class,SimpleDeserializerFactory.class);
Ross
-----Original Message-----
From: Anne Thomas Manes [mailto:[EMAIL PROTECTED]
Sent: Friday, July 29, 2005 12:35 PM
To: [email protected]
Subject: Re: SAXException: Found character data inside an array element
while deserializing
I think you want to invoke the request like this:
Object ret = call.invoke(x);
When using WRAPPED, Axis automatically marshals the parameters into
the wrapper element for you.
Alternatively, you could change the style to DOCUMENT:
call.setOperationStyle(org.apache.axis.constants.Style.DOCUMENT)
Anne
On 7/27/05, Yakulis, Ross (Ross) <[EMAIL PROTECTED]> wrote:
> I am using Java2Wsdl and WSDL2Java to create a web service and also invoke
> it. This all works fine.
> However, in my end use of axis, in an applicaiton developlent tool, I cannot
> use the generated
> XXXSoapBIndingStub.java code, rather I need to dynamically create the call.
> In looking at the
> code that WSDL2Java generates I have tried to distill that down. However in
> my code when I call the
> service, I getn teh SAXException: Found character data inside an array
> element while deserializing,
> even though the same SOAP messages are send in both cases. This leads me to
> believe that I am
> not setting up something correctly when invoking the web service. However I
> am at a loss to
> determine what I am missing. The service is a "wrapped" service. I only
> have this problem for
> an array of simple types. Using an array of benas things work (though the
> code below would
> be a tad different.
>
> Any thoughts?
>
> Ross
>
> ------------ Source Code Simplified version ----------------------------
>
> public class CallService {
>
> public static void main(String[] args) {
> try {
> Service service = new Service();
> Call call = (Call) service.createCall();
>
> call.setTargetEndpointAddress("http://localhost:6060/axis/services/SimpleWrap");
> call.setOperationName("srIntArray");
> call.setOperationStyle(org.apache.axis.constants.Style.WRAPPED);
> call.setOperationUse(org.apache.axis.constants.Use.LITERAL);
> call.setUseSOAPAction(true);
> call.setSOAPActionURI("");
> call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR,
> Boolean.FALSE);
> call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS,
> Boolean.FALSE);
> call.setEncodingStyle(null);
>
> call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
> service.setTypeMappingVersion("1.2");
>
> call.registerTypeMapping(int.class, new
> QName("http://www.w3.org/2001/XMLSchema", "int"),
> ArraySerializerFactory.class,
> ArrayDeserializerFactory.class);
> call.addParameter(new QName("urn:x.SimpleWrap", "values"), new
> QName("http://www.w3.org/2001/XMLSchema", "int"),
> ParameterMode.IN);
> call.setReturnType(new
> javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"));
> call.setReturnClass(int[].class);
> call.setReturnQName(new
> javax.xml.namespace.QName("urn:x.SimpleWrap", "srIntArrayReturn"));
>
> /* gather up the input parameters */
> Object[] parms = new Object[1];
> int[] x = new int[2];
> x[0] = 450;
> x[1] = 340;
> parms[0] = x;
>
> /* make the call */
> Object ret = call.invoke(parms);
>
> } catch (Exception e) {
> System.out.println("Error on Web Serivce call:" + e);
> e.printStackTrace();
> }
> }
> }
>
> ---------- WSDL ------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions targetNamespace="urn:x.SimpleWrap"
> xmlns:impl="urn:x.SimpleWrap" xmlns:intf="urn:x.SimpleWrap"
> xmlns:apachesoap="http://xml.apache.org/xml-soap"
> xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
> <!--WSDL created by Apache Axis version: 1.2
> Built on May 03, 2005 (02:20:24 EDT)-->
> <wsdl:types>
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> targetNamespace="urn:x.SimpleWrap" elementFormDefault="qualified">
> <element name="add">
> <complexType>
> <sequence>
> <element name="a" type="xsd:int"/>
> <element name="b" type="xsd:int"/>
> </sequence>
> </complexType>
> </element>
> <element name="addResponse">
> <complexType>
> <sequence>
> <element name="addReturn" type="xsd:int"/>
> </sequence>
> </complexType>
> </element>
> <element name="srInfo">
> <complexType>
> <sequence>
> <element name="info" type="impl:Info"/>
> </sequence>
> </complexType>
> </element>
> <complexType name="Info">
> <sequence>
> <element name="age" type="xsd:int"/>
> <element name="name" nillable="true" type="xsd:string"/>
> <element name="phone" nillable="true" type="xsd:string"/>
> </sequence>
> </complexType>
> <element name="srInfoResponse">
> <complexType>
> <sequence>
> <element name="srInfoReturn" type="impl:Info"/>
> </sequence>
> </complexType>
> </element>
> <element name="srInfoArray">
> <complexType>
> <sequence>
> <element name="info" type="impl:Info" maxOccurs="unbounded"/>
> </sequence>
> </complexType>
> </element>
> <element name="srInfoArrayResponse">
> <complexType>
> <sequence>
> <element name="srInfoArrayReturn" type="impl:Info"
> maxOccurs="unbounded"/>
> </sequence>
> </complexType>
> </element>
> <element name="srIntArray">
> <complexType>
> <sequence>
> <element name="values" type="xsd:int" maxOccurs="unbounded"/>
> </sequence>
> </complexType>
> </element>
> <element name="srIntArrayResponse">
> <complexType>
> <sequence>
> <element name="srIntArrayReturn" type="xsd:int" maxOccurs="unbounded"/>
> </sequence>
> </complexType>
> </element>
> </schema>
> </wsdl:types>
>
> <wsdl:message name="srInfoArrayResponse">
>
> <wsdl:part name="parameters" element="impl:srInfoArrayResponse"/>
>
> </wsdl:message>
>
> <wsdl:message name="srInfoArrayRequest">
>
> <wsdl:part name="parameters" element="impl:srInfoArray"/>
>
> </wsdl:message>
>
> <wsdl:message name="srInfoResponse">
>
> <wsdl:part name="parameters" element="impl:srInfoResponse"/>
>
> </wsdl:message>
>
> <wsdl:message name="srIntArrayResponse">
>
> <wsdl:part name="parameters" element="impl:srIntArrayResponse"/>
>
> </wsdl:message>
>
> <wsdl:message name="addRequest">
>
> <wsdl:part name="parameters" element="impl:add"/>
>
> </wsdl:message>
>
> <wsdl:message name="srInfoRequest">
>
> <wsdl:part name="parameters" element="impl:srInfo"/>
>
> </wsdl:message>
>
> <wsdl:message name="addResponse">
>
> <wsdl:part name="parameters" element="impl:addResponse"/>
>
> </wsdl:message>
>
> <wsdl:message name="srIntArrayRequest">
>
> <wsdl:part name="parameters" element="impl:srIntArray"/>
>
> </wsdl:message>
>
> <wsdl:portType name="SimpleWrap">
>
> <wsdl:operation name="add">
>
> <wsdl:input name="addRequest" message="impl:addRequest"/>
>
> <wsdl:output name="addResponse" message="impl:addResponse"/>
>
> </wsdl:operation>
>
> <wsdl:operation name="srInfo">
>
> <wsdl:input name="srInfoRequest" message="impl:srInfoRequest"/>
>
> <wsdl:output name="srInfoResponse" message="impl:srInfoResponse"/>
>
> </wsdl:operation>
>
> <wsdl:operation name="srInfoArray">
>
> <wsdl:input name="srInfoArrayRequest"
> message="impl:srInfoArrayRequest"/>
>
> <wsdl:output name="srInfoArrayResponse"
> message="impl:srInfoArrayResponse"/>
>
> </wsdl:operation>
>
> <wsdl:operation name="srIntArray">
>
> <wsdl:input name="srIntArrayRequest"
> message="impl:srIntArrayRequest"/>
>
> <wsdl:output name="srIntArrayResponse"
> message="impl:srIntArrayResponse"/>
>
> </wsdl:operation>
>
> </wsdl:portType>
>
> <wsdl:binding name="SimpleWrapSoapBinding" type="impl:SimpleWrap">
>
> <wsdlsoap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
>
> <wsdl:operation name="add">
>
> <wsdlsoap:operation soapAction=""/>
>
> <wsdl:input name="addRequest">
>
> <wsdlsoap:body use="literal"/>
>
> </wsdl:input>
>
> <wsdl:output name="addResponse">
>
> <wsdlsoap:body use="literal"/>
>
> </wsdl:output>
>
> </wsdl:operation>
>
> <wsdl:operation name="srInfo">
>
> <wsdlsoap:operation soapAction=""/>
>
> <wsdl:input name="srInfoRequest">
>
> <wsdlsoap:body use="literal"/>
>
> </wsdl:input>
>
> <wsdl:output name="srInfoResponse">
>
> <wsdlsoap:body use="literal"/>
>
> </wsdl:output>
>
> </wsdl:operation>
>
> <wsdl:operation name="srInfoArray">
>
> <wsdlsoap:operation soapAction=""/>
>
> <wsdl:input name="srInfoArrayRequest">
>
> <wsdlsoap:body use="literal"/>
>
> </wsdl:input>
>
> <wsdl:output name="srInfoArrayResponse">
>
> <wsdlsoap:body use="literal"/>
>
> </wsdl:output>
>
> </wsdl:operation>
>
> <wsdl:operation name="srIntArray">
>
> <wsdlsoap:operation soapAction=""/>
>
> <wsdl:input name="srIntArrayRequest">
>
> <wsdlsoap:body use="literal"/>
>
> </wsdl:input>
>
> <wsdl:output name="srIntArrayResponse">
>
> <wsdlsoap:body use="literal"/>
>
> </wsdl:output>
>
> </wsdl:operation>
>
> </wsdl:binding>
>
> <wsdl:service name="SimpleWrapService">
>
> <wsdl:port name="SimpleWrap" binding="impl:SimpleWrapSoapBinding">
>
> <wsdlsoap:address location="http://localhost:8080/SimpleWrap"/>
>
> </wsdl:port>
>
> </wsdl:service>
>
> </wsdl:definitions>
>