axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Nibin K J (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AXIS2-5063) Provide support for complex object types.
Date Mon, 25 Jul 2011 08:47:10 GMT

    [ https://issues.apache.org/jira/browse/AXIS2-5063?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13070372#comment-13070372
] 

Paul Nibin K J commented on AXIS2-5063:
---------------------------------------

Hi,

I tried to create a service which receives and returns Document object. My service class is:

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;

public class DocumentTest
{
    public Document echoDocument( Document doc ) throws Exception
    {
        Transformer trans;
        try
        {
            trans = TransformerFactory.newInstance().newTransformer();
            trans.setOutputProperty( OutputKeys.METHOD, "xml" );
            trans.setOutputProperty( OutputKeys.INDENT, "yes" );
            trans.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount", Integer.toString(
2 ) );

            StringWriter sw = new StringWriter();
            StreamResult result = new StreamResult( sw );
            DOMSource source = new DOMSource( doc.getDocumentElement() );

            trans.transform( source, result );
            String xmlString = sw.toString();
            System.out.println( xmlString );
            return doc;
        }
        catch ( Exception e )
        {
            throw new Exception( "Exception occured while printing the document.", e );
        }
    }
}

I deployed the service as a POJO and generated the client stub using the following code.

WSDL2Java.main( new String []
        { "-o", ".", "-uw", "-u", "-uri", "http://localhost:8080/axis2/services/DocumentTest?wsdl"
} );

My client code to test is:

import java.io.IOException;
import java.io.StringReader;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class Axis2DocumentTest
{
    public static void main( String [] args ) throws DocumentTestExceptionException, ParserConfigurationException,
            SAXException, IOException
    {
        DocumentTestStub stub = new DocumentTestStub();
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document document = builder.parse( new InputSource( new StringReader(
                "<person id=\"1\"><name>Paul</name></person>" ) )
);
        Object echoDocument = stub.echoDocument( document );
        System.out.println( echoDocument );
    }
}

When I try to invoke the service, I am getting the following exception in the client side.

Exception in thread "main" 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:78)
      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.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:621)
      at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)
      at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404)
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231)
      at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
      at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
      at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
      at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
      at org.apache.ws.axis2.DocumentTestStub.echoDocument(DocumentTestStub.java:190)
      at org.apache.ws.axis2.Axis2DocumentTest.main(Axis2DocumentTest.java:23)
Caused by: javax.xml.stream.XMLStreamException: Unknow type can not serialize
      at org.apache.axis2.databinding.utils.ConverterUtil.serializeAnyType(ConverterUtil.java:1472)
      at org.apache.ws.axis2.EchoDocument.serialize(EchoDocument.java:137)
      at org.apache.ws.axis2.EchoDocument.serialize(EchoDocument.java:93)
      at org.apache.axis2.databinding.ADBDataSource.serialize(ADBDataSource.java:90)
      at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:701)
      at org.apache.axiom.om.impl.util.OMSerializerUtil.serializeChildren(OMSerializerUtil.java:564)
      at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:904)
      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:74)
      ... 18 more

Please check this case.

Also I find that the return type of the Object DocumentTestStub.echoDocument( Document doc
) is java.lang.Object. Shouldn't this be Document?

Thanks,
Paul

> Provide support for complex object types.
> -----------------------------------------
>
>                 Key: AXIS2-5063
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5063
>             Project: Axis2
>          Issue Type: Improvement
>          Components: adb
>    Affects Versions: 1.5.4, 1.6.0
>            Reporter: Muhammed Shariq
>            Assignee: Sagara Gunathunga 
>             Fix For: 1.7.0
>
>
> It is not possible to pass complex type objects via a web service invocation. The following
error is thrown while attempting to do so.
> [ERROR] Exception occurred while trying to invoke service method echoArray
> org.apache.axis2.AxisFault: Unknow type {http://www.w3.org/2001/XMLSchema}string
> 	at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:349)
> 	at org.apache.axis2.databinding.utils.BeanUtil.processObject(BeanUtil.java:827)
> 	at org.apache.axis2.databinding.utils.BeanUtil.ProcessElement(BeanUtil.java:717)
> 	at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:655)
> 	at org.apache.axis2.rpc.receivers.RPCUtil.processRequest(RPCUtil.java:153)
> 	at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:206)
> 	at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
> 	at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
> 	at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
> 	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
> 	at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
> 	at org.apache.axis2.transport.http.HTTPWorker.service(HTTPWorker.java:296)
> 	at org.apache.axis2.transport.http.server.AxisHttpService.doService(AxisHttpService.java:281)
> 	at org.apache.axis2.transport.http.server.AxisHttpService.handleRequest(AxisHttpService.java:187)
> 	at org.apache.axis2.transport.http.server.HttpServiceProcessor.run(HttpServiceProcessor.java:82)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> 	at java.lang.Thread.run(Thread.java:662)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


Mime
View raw message