You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rampart-dev@ws.apache.org by "Amila Chinthaka Suriarachchi (JIRA)" <ji...@apache.org> on 2010/04/28 13:39:44 UTC

[jira] Commented: (AXIS2-4408) the problem of In-only method with throw exception

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

Amila Chinthaka Suriarachchi commented on AXIS2-4408:
-----------------------------------------------------

I had a look at the current pojo exception handling and found a lot issues. 

Lets take a business methods like this,
    public String test5(String test) throws BussinessException, CustomException {
        CustomException customException = new CustomException();
        customException.setErrorCode(3);
        customException.setErrorMessage(test);
        throw customException;
    }

 public void test6(String test) throws BussinessException, CustomException {
        CustomException customException = new CustomException();
        customException.setErrorCode(5);
        customException.setErrorMessage(test);
        throw customException;
    }

There are two things to be done in order to handle exceptions properly for such a method.

1.Display two exceptions as two fault messages in the wsdl.
These fault messages should refer to schema elements. But there is no need to extend the complex type of this element from a common complex type called 'Exception' Since it is enough to send the element in the soap fault detail part. For exceptions of the type java.lang.Exception we can generate a complex type which has a child element called message to send the message.

2.Send the displayed fault element in the soap fault detail element.
For plain Exceptions the exception message can directly be generated. For others Exception class can be serialized using the existing utility classes.


first will attach a patch which solve these issues.


> the problem of In-only method with throw exception
> --------------------------------------------------
>
>                 Key: AXIS2-4408
>                 URL: https://issues.apache.org/jira/browse/AXIS2-4408
>             Project: Axis2
>          Issue Type: Bug
>          Components: wsdl
>    Affects Versions: 1.4.1
>         Environment: jdk1.4
>            Reporter: qilin
>            Priority: Blocker
>             Fix For: 1.6
>
>         Attachments: PiskvornikServerSOAP.wsdl, PiskvornikServerSOAPStub.java, PrintService.java, PrintService.xml, services.xml
>
>
> 1.The Service Code:
> public class PrintService {
> 	public void print(String aMessage) throws Exception{
> 		System.out.println(aMessage);
> 	}
> }
> 2.The Service.xml:
> <service name="PrintService" scope ="application" >
> 	<Description>
> 		Please Type your service description here
> 	</Description>
> 	<messageReceivers>
> 		<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
> 		<messageReceiver  mep="http://www.w3.org/2004/08/wsdl/in-out"  class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
> 	</messageReceivers>
> 	
> 	<parameter name="ServiceClass" locked="false">soap.test.PrintService</parameter>
> 	
> 	 <!-- 
> 	<operation name="print">
>         <messageReceiver 
> 		class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
>     </operation>
>    
>     -->
> </service>
> 3. generate clent code by wsdl2java and run test
>     I get the exception
>    java.lang.UnsupportedOperationException: An access occurred that is not valid.
> 	at org.apache.axis2.description.InOnlyAxisOperation.getMessage(InOnlyAxisOperation.java:109)
> 	at org.apache.axis2.util.MessageContextBuilder.createOutMessageContext(MessageContextBuilder.java:190)
> 	at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:37)
> 	at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:100)
> 	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
> 	at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
> 	at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:133)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
> 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:199)
> 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:145)
> 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
> 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
> 	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
> 	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
> 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:139)
> 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
> 	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
> 	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
> 	at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2460)
> 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
> 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
> 	at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:119)
> 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
> 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
> 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
> 	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
> 	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
> 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
> 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
> 	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
> 	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
> 	at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:157)
> 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
> 	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
> 	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
> 	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
> 	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
> 	at java.lang.Thread.run(Thread.java:534)
> 4. remove the service.xml comment,the  'An access occurred that is not valid.' not Occurred
> 5. get the new wdsl from web site,then generate clent code by wsdl2java and run same test
>     I get Exception
>     The input stream for an incoming message is null.
> org.apache.axis2.AxisFault: The input stream for an incoming message is null.
> 	at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:72)
> 	at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:353)
> 	at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
> 	at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
> 	at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
>   if I do not re generate clent code ,the exception will not Occurred.
>  Finally , I fount that wsdl  is different when I remove the comment, 
> <wsdl:input message="ns:printRequest" wsaw:Action="urn:print"/>
> <wsdl:fault message="ns:Exception" name="Exception" wsaw:Action="urn:printException"/>
> --->
> <wsdl:input message="ns:printRequest" wsaw:Action="urn:print"/>
> <wsdl:output message="ns:printResponse" wsaw:Action="urn:printResponse"/>
> <wsdl:fault message="ns:Exception" name="Exception" wsaw:Action="urn:printException"/>
> Then generate client code is changed :
> __operation = new org.apache.axis2.description.RobustOutOnlyAxisOperation();    //right!
> --->
> __operation = new org.apache.axis2.description.OutInAxisOperation();                     //error!
> By the way, if 
> public void print(String aMessage) throws Exception ---> public void print(String aMessage) 
> will have no problem!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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