CaptainMorgan
CaptainMorgan

Reputation: 1251

Axis2 web service stub failing

We have a website written in Java that makes a web service call. Recently, we have noticed that we are recieving a null response from the web service (The endpoint is a 3rd party not maintained by us). I've tracked down the point at which our code is failing and it's in our stub. See the code below, the code is failing between the two System.out.println lines. My problem is that no exception is thrown, so I don't know why the _operationClient.execute(true); fails. Would anyone have any idea how I can go about solving this?

    public SuggestXResponseE suggestX(SuggestXE suggestX0)
            throws java.rmi.RemoteException {
        org.apache.axis2.context.MessageContext _messageContext = null;
        try {
            org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName());
            _operationClient.getOptions().setAction("http://www.test.com/service/suggestX");
            _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);


            addPropertyToOperationClient(_operationClient, org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, "&");

            // create a message context
            _messageContext = new org.apache.axis2.context.MessageContext();


            // create SOAP envelope with that payload
            org.apache.axiom.soap.SOAPEnvelope env = null;

            env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
                    suggestX0,
                    optimizeContent(new javax.xml.namespace.QName("http://www.test.com/service",
                    "suggestX")));
            //adding SOAP soap_headers
            _serviceClient.addHeadersToEnvelope(env);
            // set the message context with that soap envelope
            _messageContext.setEnvelope(env);
            // add the message contxt to the operation client
            _operationClient.addMessageContext(_messageContext);

System.out.println("Log message 1");
            //execute the operation client
            _operationClient.execute(true);
System.out.println("Log message 2");

            org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext(
                    org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();

            java.lang.Object object = fromOM(
                    _returnEnv.getBody().getFirstElement(),
                    SuggestXResponseE.class,
                    getEnvelopeNamespaces(_returnEnv));

            return (SuggestXResponseE) object;

        } catch (org.apache.axis2.AxisFault f) {
        // Handle exception.
    } 
        finally {
            _messageContext.getTransportOut().getSender().cleanup(_messageContext);
        }
    }

Upvotes: 0

Views: 2665

Answers (1)

Kenster
Kenster

Reputation: 25439

System.out.println("Log message 1");
        //execute the operation client
        _operationClient.execute(true);
System.out.println("Log message 2");

If you're getting the first log message but not the second one, then one of two things is happening:

  1. System.exit() is being called somewhere within _operationClient.execute(). You'd recognize this by the fact the process exits.

  2. More likely, _operationClient.execute() is throwing something.

You say it's not throwing an exception, but it could be throwing an Error or some other kind of Throwable. It's not normally advised to catch non-Exception throwables, but you could add some code to do it temporarily:

try {
    _operationClient.execute(true);
} catch (Throwable t) {
    log.error(t);
    throw t;
}

You might find that you're getting an OutOfMemoryError or a NoClassDefFoundError because some jar is missing from your deployment, for example.

Upvotes: 2

Related Questions