开发者

How to return a complex object from an axis web service

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.JWSHan开发者_如何转开发dler">
            <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?


I sorted this by following information provided at other forums.

We need to use <beanMapping/> if complex types need to be returned.

Thank you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜