How to return a complex object in axis web service .

Posted by jani on Stack Overflow See other posts from Stack Overflow or by jani
Published on 2010-03-01T05:12:23Z Indexed on 2010/03/19 0:51 UTC
Read the original article Hit count: 549

Filed under:
|

Hi all,

I am writing a simple web service to return an object with 2 properties.

I am embedding the service into an existing web application.

My wsdd looks like this.

<globalConfiguration>
    <parameter name="adminPassword" value="admin"/>
    <parameter name="sendXsiTypes" value="true"/>
    <parameter name="sendMultiRefs" value="true"/>
    <parameter name="sendXMLDeclaration" value="true"/>
    <parameter name="axis.sendMinimizedElements" value="true"/>

    <requestFlow>
        <handler type="java:org.apache.axis.handlers.JWSHandler">
            <parameter name="scope" value="session"/>
        </handler>
        <handler type="java:org.apache.axis.handlers.JWSHandler">
            <parameter name="scope" value="request"/>
            <parameter name="extension" value=".jwr"/>
        </handler>
    </requestFlow>
</globalConfiguration>

<handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/>
<handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
<handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>

<transport name="http">
    <requestFlow>
        <handler type="URLMapper"/>
        <handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
    </requestFlow>
</transport>


<transport name="local">
    <responseFlow>
        <handler type="LocalResponder"/>
    </responseFlow>
</transport>


<service name="helloService" provider="java:RPC" style="document" use="literal">
    <parameter name="className" value="ws.example.HelloService"/>
    <parameter name="allowedMethods" value="*"/>
    <parameter name="scope" value="application"/>
</service>

I am able to deploy it successfully.

If I try to invoke the method which returns a String, it is successfully returning the String.

But when I invoke the method which returns an object, I am getting the following error.

AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: org.xml.sax.SAXParseException: Premature end of file. faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: Premature end of file. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(SAXParser.java:395) at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) at org.apache.axis.Message.getSOAPEnvelope(Message.java:424) at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796) at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) at org.apache.axis.client.Call.invokeEngine(Call.java:2765) at org.apache.axis.client.Call.invoke(Call.java:2748) at org.apache.axis.client.Call.invoke(Call.java:2424) at org.apache.axis.client.Call.invoke(Call.java:2347) at org.apache.axis.client.Call.invoke(Call.java:1804) at ws.example.ws.HelloServiceSoapBindingStub.getAwardById(HelloServiceSoapBindingStub.java:202) at Test.main(Test.java:21)

Can any body help?

Thanks in advance

© Stack Overflow or respective owner

Related posts about axis

Related posts about fault