4 Replies Latest reply: Jan 14, 2013 7:16 PM by BK574 RSS

    Error Handling for SOA Server

    BK574
      Hi All,

      I converted a java code into a webservice with the help of jdeveloper and deployed it into weblogic server, and it is working fine when I am invoking it through the SOA server. But, when I am passing some wrong input values I should suppose to get error, but I don't see any errors inside em and status is showing as completed. At the same time, I am able to view the complete error stack trace inside soa_server1 command prompt (StartManagedWeblogic soa_server1). How can I catch this errors inside em. I added catchall block but no success. My requirement is to catch this errors inside em and need to email it.

      Thanks,
        • 1. Re: Error Handling for SOA Server
          vladodias
          Hi,

          The problem is probably in the java code... you have to throw the exception out of the @WebMethod so it can be captured outside... if you have, anywhere in the code, a try/catch with a printStackTrace with no throw you will see a behaviour like the one you are observing...

          Hope this helps...

          Cheers,
          Vlad
          • 2. Re: Error Handling for SOA Server
            BK574
            Hi,

            Thanks for your reply. Can you let me know, where to modify the code in order to print the error inside em.

            package com.ka;

            import com.agile.api.APIException;
            import com.agile.api.AgileSessionFactory;
            import com.agile.api.IAdmin;
            import com.agile.api.IAgileClass;
            import com.agile.api.IAgileSession;
            import com.agile.api.IServiceRequest;

            import com.agile.api.ServiceRequestConstants;

            import java.text.DateFormat;

            import java.text.SimpleDateFormat;

            import java.util.Calendar;
            import java.util.HashMap;

            import javax.jws.WebService;

            import javax.xml.soap.SOAPException;
            import javax.xml.ws.BindingType;
            import javax.xml.ws.WebFault;
            import javax.xml.ws.soap.SOAPBinding;

            @WebService(portName = "ClassTestSoap12HttpPort")
            @BindingType(SOAPBinding.SOAP12HTTP_BINDING)
            public class ClassTest {

            public String TestAPIMet(String complaintNumber, String description, String disposition, String severity, String workflow ) {
            IAgileSession m_session=null;
            IAdmin admin=null;

            try {
            String error="invalid";
            HashMap params = new HashMap();
            params.put(AgileSessionFactory.USERNAME, "**********");
            params.put(AgileSessionFactory.PASSWORD, "***********************");
            System.out.println(""+params);
            AgileSessionFactory instance = AgileSessionFactory.getInstance("http://*******************************");
            System.out.println(""+instance);
            m_session = instance.createSession(params);
            System.out.println("Session ID:"+m_session);
            admin = m_session.getAdminInstance();
            IAgileClass cls = admin.getAgileClass( "ProblemReport" );
            System.out.println("Class ID:"+cls);
            IServiceRequest psr = (IServiceRequest)m_session.createObject( "ProblemReport", complaintNumber);
            psr.setValue(ServiceRequestConstants.ATT_COVER_PAGE_DESCRIPTION, description);
            psr.setValue(ServiceRequestConstants.ATT_COVER_PAGE_DISPOSITION, disposition);

            psr.setValue(ServiceRequestConstants.ATT_COVER_PAGE_SEVERITY, severity);

            psr.setValue(ServiceRequestConstants.ATT_COVER_PAGE_WORKFLOW, workflow);
            DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a z");
            Calendar cal = Calendar.getInstance();
            psr.setValue( ServiceRequestConstants.ATT_COVER_PAGE_EXPECTED_RESOLUTION_DATE, dateFormat.format(cal.getTime()));

            }

            catch (APIException e) {
            e.printStackTrace();
            e.getMessage();
            e.getRootCause();
            }

            finally {
            System.out.println("Session is closing");
            m_session.close();
            System.out.println("Session closed");
            }
            return "Success";
            }
            }
            • 3. Re: Error Handling for SOA Server
              vladodias
              Where you have this...
              catch (APIException e) {
              e.printStackTrace();
              e.getMessage();
              e.getRootCause();
              }
              Change into this...
              catch (APIException e) {
              e.printStackTrace();  // this is printing the error stack trace to soa_server1 command prompt output
              throw new RuntimeException(e);
              }
              This should solve... I didn't verify the syntax... Let me know if you have any issue...

              Cheers,
              Vlad
              • 4. Re: Error Handling for SOA Server
                BK574
                Thank you very much, it's working now. I can see the error message inside em.