If  you want to throw exceptions they must be wrapped into web service
exceptions.

**
Martin

2010/10/12 paul nibin <[email protected]>:
> Hi,
>
>                Thank you so much for the response.
>
> I know that it will work if the "throws Exception" clause is removed.
>
> But I need to support this feature. Is there any way to support invoking a
> method which does not take any input arguments, returns void and throws an
> exception?
>
> Paul
>
> On Tue, Oct 12, 2010 at 11:01 AM, Martin Makundi
> <[email protected]> wrote:
>>
>> Hi!
>>
>> Try removing your unnecessary "throws Exception" clause.
>>
>> **
>> Martin
>>
>> 2010/10/12 paul nibin <[email protected]>:
>> > Hi all,
>> >
>> >        I am trying to invoke a simple web service.
>> >
>> > public class SimpleTestVoid
>> > {
>> >     public void printMessage() throws Exception
>> >     {
>> >         System.out.println( "Hello world" );
>> >     }
>> > }
>> >
>> >
>> > The WSDL is generated fine. Generated the client. But when invoking the
>> > service, I am getting an exception.
>> >
>> > java.lang.UnsupportedOperationException: An access occurred that is not
>> > valid.
>> >         at
>> >
>> > org.apache.axis2.description.InOnlyAxisOperation.getMessage(InOnlyAxisOperation.java:117)
>> >         at
>> >
>> > org.apache.axis2.util.MessageContextBuilder.createOutMessageContext(MessageContextBuilder.java:183)
>> >         at
>> >
>> > org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:37)
>> >         at
>> >
>> > org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
>> >         at
>> > org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)
>> >         at
>> >
>> > org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:167)
>> >         at
>> > org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:142)
>> >
>> > I debugged some part of the code.
>> >
>> > When the service is deployed, according to the signature of the method,
>> > it
>> > is creating a InOnlyAxisOperation with "robust-in-only" as the message
>> > exchange pattern( it is not taking any input params and throwing an
>> > exception).
>> >
>> >
>> > org.apache.axis2.deployment.util.UtilsgetAxisOperationForJmethod()
>> >
>> >      if ("void".equals(method.getReturnType().getName())) {
>> >             if (method.getExceptionTypes().length > 0) {
>> >                 operation = AxisOperationFactory
>> >
>> > .getAxisOperation(WSDLConstants.MEP_CONSTANT_ROBUST_IN_ONLY);
>> >             } else {
>> >                 operation = AxisOperationFactory
>> >
>> > .getAxisOperation(WSDLConstants.MEP_CONSTANT_IN_ONLY);
>> >             }
>> >
>> > If MEP_CONSTANT_IN_ONLY message exchange pattern is used, then all works
>> > fine. But if there a method which does not take any input parameters and
>> > throws some exception, then this issue comes.
>> >
>> > org.apache.axis2.description.AxisOperationFactory.getAxisOperation(int
>> > mepURI)
>> >
>> >             case WSDLConstants.MEP_CONSTANT_ROBUST_IN_ONLY : {
>> >                 abOpdesc = new InOnlyAxisOperation();
>> >
>> >
>> > abOpdesc.setMessageExchangePattern(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY);
>> >                 break;
>> >
>> > So when the invoking the method using a client, in
>> >
>> > org.apache.axis2.util.MessageContextBuilder.createOutMessageContext(MessageContext
>> > inMessageContext)
>> >
>> > if (ao != null){
>> >
>> >
>> > newmsgCtx.setAxisMessage(ao.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
>> >         }
>> >
>> > Since a0 is a org.apache.axis2.description.InOnlyAxisOperation, the
>> > following getMessage is invoked, so it is throwing this
>> > UnsupportedOperationException.
>> >
>> > public AxisMessage getMessage(String label) {
>> >         if (WSDLConstants.MESSAGE_LABEL_IN_VALUE.equals(label)) {
>> >             return (AxisMessage) getChild("inMessage");
>> >         } else {
>> >             throw new
>> > UnsupportedOperationException(Messages.getMessage("invalidacess"));
>> >         }
>> >     }
>> >
>> > If any more info is required please let me know. Hoping for a response..
>> >
>> > Please.. I need help with this one...
>> >
>> > Thanks,
>> > Paul
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to