4

I've got problem sending an array of string as parameter to a web service method, given in a specific wsdl. When am trying to send an array of strings, I get the following error.

Error:

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode: 
faultString: org.xml.sax.SAXException: Bad types (class java.util.ArrayList > 
class usdjws65.ArrayOfString)
faultActor: 
faultNode: 
faultDetail: 
            {http://xml.apache.org/axis/}hostname:SSLSPSD001

org.xml.sax.SAXException: Bad types (class java.util.ArrayList -> class usdjws65.ArrayOfString)
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at  org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)

Code written:

Call call1 = objService1.createCall(port1);
call1.setTargetEndpointAddress(targetEndPoint);
call1.addParameter("int_1", XMLType.XSD_INT, Integer.class,
                ParameterMode.IN);
        call1.addParameter("String_1", QNAME_TYPE_STRING, ParameterMode.IN);
        call1.addParameter("String_2", QNAME_TYPE_STRING_ARRAY,
                java.lang.String[].class, ParameterMode.IN);
        call1.addParameter("String_3", QNAME_TYPE_STRING_ARRAY,
                java.lang.String[].class, ParameterMode.IN);
        call1.addParameter("String_4", QNAME_TYPE_STRING, ParameterMode.IN);
        call1.addParameter("String_5", QNAME_TYPE_STRING_ARRAY,
                java.lang.String[].class, ParameterMode.IN);
        call1.addParameter("String_6", QNAME_TYPE_STRING, ParameterMode.IN);
        call1.addParameter("String_7", QNAME_TYPE_STRING, ParameterMode.IN);

        // --- Done adding PARAM's

        String[] attrVals = { "description", "test from soapUI",
                "customer", ticketHandle, "type", "I" };
        String[] attributes = { "status", "ref_num" };

        Object[] params1 = { new Integer(sid), ticketHandle, attrVals, "",
                "cr_tpl:400005", attributes, "", "" };

        String res = null;
        try {
            call1.invoke(params1);

Thanks !!!! -Aj

=========================================================

Update-1:

I added a class named ArrayOfString with following code in it. protected java.lang.String[] string;

public ArrayOfString() {
}

public ArrayOfString(java.lang.String[] string) {
    this.string = string;
}

public java.lang.String[] getString() {
    return string;
}

public void setString(java.lang.String[] string) {
    this.string = string;
}

and thus did the following, ArrayOfString attrVals = new ArrayOfString(); attrVals.setString(new String[] { "customer", "test from soapUI", "customer", ticketHandle, "type", "I" });

Similarly, for attributes variable of type 'ArrayOfString'.

But now, I get the following error::

AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: java.io.IOException: No serializer found for class ArrayOfString in registry org.apache.axis.encoding.TypeMappingDelegate@ef2c60 faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:java.io.IOException: No serializer found for class ArrayOfString in registry org.apache.axis.encoding.TypeMappingDelegate@ef2c60 at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1507) at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:980) at org.apache.axis.encoding.SerializationContext.outputMultiRefs(SerializationContext.java:1055) at org.apache.axis.message.SOAPBody.outputImpl(SOAPBody.java:145) at org.apache.axis.message.SOAPEnvelope.outputImpl(SOAPEnvelope.java:478) at org.apache.axis.message.MessageElement.output(MessageElement.java:1208) at org.apache.axis.client.Call.invoke(Call.java:2757) at org.apache.axis.client.Call.invoke(Call.java:2443) at org.apache.axis.client.Call.invoke(Call.java:2366) at org.apache.axis.client.Call.invoke(Call.java:1812)


Update-2:

Here is an update on the problem that am facing. In the WSDL file, I found something like this,

complexType name="ArrayOfString"
sequence
element maxOccurs="unbounded" name="string" type="xsd:string" / 
/sequence
/complexType

Well, now that am meant to use this method,

 <element name="createRequest">
<complexType>
<sequence>
<element name="sid" type="xsd:int" /> 
<element name="creatorHandle" type="xsd:string" /> 
<element name="attrVals" type="impl:ArrayOfString" /> 
<element name="propertyValues" type="impl:ArrayOfString" /> 
<element name="template" type="xsd:string" /> 
<element name="attributes" type="impl:ArrayOfString" /> 
<element name="newRequestHandle" type="xsd:string" /> 
<element name="newRequestNumber" type="xsd:string" /> 
</sequence>
</complexType>
</element>

Now, I tried sending the parameters 'attrVals','attibutes' like this

ArrayOfstring attrVals = new ArrayOfstring();
    ArrayOfstring attributes = new ArrayOfstring();
    attrVals.setString(new String[] { "customer", "test from soapUI",
            "customer", ticketHandle, "type", "I" });
    attributes.setString(new String[] { "status", "ref_num" });

Its throwing the following exception

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode: 
faultString: java.io.IOException: No serializer found for class org.tempuri.complex.data.arrays.xsd.ArrayOfstring in registry org.apache.axis.encoding.TypeMappingDelegate@11e1e67
faultActor: 
faultNode: 
faultDetail: 
{http://xml.apache.org/axis/}stackTrace:java.io.IOException: No serializer found  for class org.tempuri.complex.data.arrays.xsd.ArrayOfstring in registry org.apache.axis.encoding.TypeMappingDelegate@11e1e67
at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1507)
at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:980)
4
  • Did you try WSDL2Java to generate client code with types? you can get the ArrayOfString and its serializer from there. Commented Jul 1, 2011 at 5:33
  • I tried WSDL2JAVA CodeGen plugin for eclipse. I'd enetered all the required details but it gives me -'InvocationTargetException'. Commented Jul 5, 2011 at 5:38
  • did you check your web-service is up? it seams that either you use the wrong url or the web-service is down. Commented Jul 5, 2011 at 7:50
  • Well this problem has been solved. And I have updated the answer in the end below(after Update-2). But the problem with WSDL2JAVA CodeGen is still persisting. Commented Jul 6, 2011 at 5:02

1 Answer 1

4

The above error has been solved. I simply registered the ArrayOfString class, String[] with the TypeRegistryMapping class. Now, it doesn't throw the above serialize error. Code edited is:

    ServiceFactory factory1 = ServiceFactory.newInstance();
    QName qnTick = new QName("http://soapinterop.org/xsd", "ArrayOfString");
    Service serviceTickReq = factory1.createService(qnTick);
    // Service serviceTickReq = new org.apache.axis.client.Service();
    TypeMappingRegistry tmr = (TypeMappingRegistry) serviceTickReq
            .getTypeMappingRegistry();
    TypeMapping tm = (TypeMapping) tmr.getDefaultTypeMapping();
    tm.register(ArrayOfString.class, qnTick, new BeanSerializerFactory(
            ArrayOfString.class, qnTick), new BeanDeserializerFactory(
            ArrayOfString.class, qnTick));

    TypeMappingRegistry tmr1 = (TypeMappingRegistry) serviceTickReq
            .getTypeMappingRegistry();
    TypeMapping tm1 = (TypeMapping) tmr1.getDefaultTypeMapping();
    tm1.register(String[].class, qnTick, new BeanSerializerFactory(
            String[].class, qnTick), new BeanDeserializerFactory(
            String[].class, qnTick));
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.