4 Replies Latest reply: Mar 7, 2011 11:48 PM by shwetank sharma RSS

Action Processing Pipeline & http:binding

Santhosh Chandrasekaran Newbie

1. ActionProcessingPipeline -
A .esb is developed with a HTTP Listener. For all exceptions we want to send a Custom XML rather thowing java exception.(Attached JBOSS HTML while thorwing a java exception from a Action class.)
We need a way stop action pipeline instead of throwing a java exception to JBOSS container , build a Custom XML and send back to consumer.

 

Attached the testCode where we trying to simulate the case (dummyExcHandling.zip) , HTTP Client O/P for the esb (JBOSS_HttpListener_Error_Output.html) .

 

In the HTML output we got our custom xml String (<pre>&lt;Error>&lt;CustomFault>We want  this XML  alone rather than full HTML JBOSS ********This is my test exception*********&lt;/CustomFault>&lt;/Error>).

 

But we need only custome output alone rather the whole JBOSS HTML page.

 

2. Need ways to generate Java Artifacts for http:binding , soap:binding for a single wsdl through JBOSS IDE.
Note: soap:binding works fine with JBOSS DEV Studio.

 

Attached the wsdl storelocator.wsdl and used in IDE to generate JAX-WS artifacts (Webservices > Generate Java Bean Skeleton).

 

It generates JAXB Objects .

org.tempuri.Address.java
org.tempuri.ArrayOfStoreLocatorResponse.java
org.tempuri.FindStore.java
org.tempuri.FindStoreResponse.java
org.tempuri.ObjectFactory.java
org.tempuri.package-info.java
org.tempuri.StoreLocatorRequest.java
org.tempuri.StoreLocatorResponse.java

 

And Aborts throwing an exception (Attached the stacktrace Exception.txt)

 

Failed to generate implementation class
    org.eclipse.core.runtime.CoreException: Failed to Generate Web Service code, please check the log for more details

  • 1. Re: Action Processing Pipeline & http:binding
    Tom Eicher Newbie

    1. either catch and handle the exceptions in ActionPipelineProcessor.process()

    or implement ActionPipelineProcessor.processException()

    Cheers, Tom.

  • 2. Re: Action Processing Pipeline
    Ray Ploski Newbie

    I beleive what Kapil wants to accomplish is gracefully handle the response displayed to the service consumer.  There are a couple of ways to accomplish this:  implement a servlet filter that provides a more succint general error message or extend HttpGatewayServlet and reimplment its processServiceRequest() method to decorate the caught FaultMessageException in a meaningful way.  I would recommend against the extending the GatewayServlet because it will limit your capabilities to upgrade in the future.

     

    By using a combination of ActionPipelineProcessor.processException() to prepare the response with a customized HttpFilter to decorate the response you will be able to provide a clean error message to your end-client without exposing jboss stack traces.

     

    e.g. Filter

     

    import java.io.IOException;import javax.servlet.*;
    import javax.servlet.http.*;
    import org.jboss.logging.Logger;
    
    public class ReplyHeaderFilter implements  Filter {
    
    
        static Logger log  = Logger.getLogger( ReplyHeaderFilter.class );
    
    
        public void init(FilterConfig config) {
    
                //Possible use this to pull config params of the error page.
        }
    
        public void doFilter(ServletRequest request,  
    
         ServletResponse response, FilterChain chain) throws 
         IOException, ServletException {             HttpServletResponse httpResponse = (HttpServletResponse)response;
            try {
    
                chain.doFilter(request, response);
            }
    
            catch (Exception e) {            
                log.error( e );
                httpResponse.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
                httpResponse.getWriter().println("Oops, something bad happend but there is nothing" +
    
                  " to see here... Move along now");
            }    }

     

     

     

    Add the filter and it's mapping to the $JBOSS_HOME/server/$SERVER_CONFIG/deployers/jbossweb.deployer/web.xml - make sure that your filter is at the top of the list.

     

    <!-- ================== Common filter Configuration ==================== -->
       <filter>
          <filter-name>BadHTTPGatewayResponseFilter</filter-name>
          <filter-class>
             com.acme.esb.web.filters.ReplyHeaderFilter
         </filter-class>
          <init-param>         <param-name>error-page</param-name>
             <param-value>/oops.html</param-value>      </init-param>
       </filter>
    
    ...
    
    <filter-mapping>
          <filter-name>BadHTTPGatewayResponseFilter</filter-name>
          <url-pattern>/*</url-pattern>
       </filter-mapping>

     

     

    To handle and prepare the error better you should use the ActionPipelineProcessor.processException().  A great set of examples for this exist within execption_faults quickstart located within the samples subdirectory.

  • 3. Re: Action Processing Pipeline & http:binding
    munimanjunath kalapati Newbie

    Hi Ray,

     

    Thanks for the  above solution.   The exception_faults very minimal   it just shows how  we can invoke various exception methods in the pipeline and its order nothing about  faultto  or anything.

     

    Is there any other alternate solutions  apart from extending the httpgateway or implementing the filter ? 

     

    Below is the solution that is required

     

    1.  Terminate the pipeline abruptly  (  this can be achieved by throwing  an exception from the custom action  pipeline )

    2.  Send  a soapfault message  instead  of  sending a  html error file

  • 4. Action Processing Pipeline & http:binding
    shwetank sharma Newbie

    Hi,

     

    I require the same functionality for my project which you have described. But no success.

     

    Can you help in case you have found something for your implementation.

     

    Thanks,

     

    Shwetank