Search code examples
web-servicesjakarta-eewsdlapache-axis

Developing webservice using Apache Axis2


I developed webservice using Apache Axis2 and the WSDL file accepts ArrayList datastructure. However, in the WSDL file it displays the type of the datastructure as follows:

<xs:complexType>
 <xs:sequence>
  <xs:element minOccurs="0" name="myDetails" nillable="true" type="xs:anyType" /> 
 </xs:sequence>
</xs:complexType>

I am trying to generate client class using Apache Axis2 based on my generated WSDL file. I am trying to forward an ArrayList details as follows :

ArrayList<String> myDetails = new ArrayList<String>();
myDetails.add("param1,param2,param3");

And forwarding the above arraylist as myDetails.toArray() for the Client class as follows :

WebserviceStub ws = new WebserviceStub("http://localhost:8080/Service/services");
CustomerDetails cd = new CustomerDetails();
cd.setMyDetails(myDetails.toArray());
CustomerDetailsResponse cds = ws.customerDetails(cd);

If I run the above client class as Java Application then it's displaying the following error message :

[INFO] Unable to sendViaPost to url[http://localhost:8080/Service/services/]
org.apache.axis2.AxisFault: Unknow type can not serialize
    at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
    at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:83)
    at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:84)
    at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499)
    at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
    at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
    at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:557)
    at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199)
    at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76)
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400)
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:438)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
Caused by: javax.xml.stream.XMLStreamException: Unknow type can not serialize
    at org.apache.axis2.databinding.utils.ConverterUtil.serializeAnyType(ConverterUtil.java:1456)
    at org.apache.axis2.databinding.ADBDataSource.serialize(ADBDataSource.java:93)
    at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:695)
    at org.apache.axiom.om.impl.util.OMSerializerUtil.serializeChildren(OMSerializerUtil.java:563)
    at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:874)
    at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.serializeInternally(SOAPEnvelopeImpl.java:283)
    at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:245)
    at org.apache.axiom.om.impl.llom.OMSerializableImpl.serializeAndConsume(OMSerializableImpl.java:193)
    at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:79)
    ... 19 more

Can we pass an ArrayList as the parameter to the webservice using Axis2 ? Does it have any limitations ? Any ideas would be greatly appreciated


Solution

  • the way of using the ArrayList on web service

    1.It support more on Set then an Array list in collection Class.

    2.you need to create Serialized Class on both the side on server side using @XmlRootElement and providing this array getter and setter on both client and user side to be serialized...