Hi Remko,
 
Thanx for the code and the way you are doing the exception propogation.
 
Now on the client end there is a problem ... that if an exception occurs the SOAPBody is empty and thus I get a NullPointerException which breaks the whole process.
 
Then I investigated slightly further and turned on the SOAPMonitor and discovered that the SAOPResponse in event of exception is empty.
 
Thus the SOAPBody on the client has to be empty and thus retriving the exception is beyond scope.
 
Also then when I carefully studied the Users Guide it clearly states that when we use MessageStyle service the axis takes a step back and thus I think the auto generation of SOAPFault does not happen.
 
From another thread in which you have replied that you dont know what your client is doing
 
refer :http://marc.theaimsgroup.com/?l=axis-user&m=105613241917142&w=2
 
So I think it would be a better idea if you can generate client and then see what happens at your end because I am always disappointed in my trials.
 
But it was fun spending the weekend exploring more about the SOAP in general and AXIS as a SOAP engine.
 
Your comments will be of great value but till far what I can make out is that if we are using Message Style I think we have to construct a custom document and return it to the client. But I am still sure and wondering if some one can advice on this issue,
 
Thanx
 
dumdum420
-----Original Message-----
From: remko de knikker [mailto:[EMAIL PROTECTED]
Sent: Friday, July 11, 2003 12:14 PM
To: [EMAIL PROTECTED]
Subject: Re: Exception handling strategy question

Bhanu,

My web service
public Document method2(Document doc1) throws RemoteException{

calls a module Hapidb, with a method  getMesh where I catch Exceptions
in my main webservice (which on return automatically catches the returned exception as well, I just throw it again.

package ws.hapi;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
import java.util.logging.FileHandler;
import java.util.logging.Logger;

import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPFault;

import org.apache.axis.MessageContext;


/**
 * @author remko caprio
 */
public class Hapidb {

        /**
         * 
         * */
        public static Vector getMesh(String spotid) throws Exception, SQLException {
            String contextHome = "/somepath/";
            Vector mesh = new Vector();
            Logger logHAPIdb = Logger.getLogger("logHAPIdb");
            MessageContext msgcxt1=null;
            SOAPBody sb1=null;
                   
            try{
           
                FileHandler fh1 = new FileHandler(contextHome + "../../logs/HAPIdb.log");
                logHAPIdb.addHandler(fh1);

                // try to connect to database
                try {
                    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
                }
                catch (Exception e) {
                    // TO DO
                }
               

                // create database connection using jdbc for MySQL connection
                String strUrl = "jdbc:mysql://biryani.med.yale.edu/db1";
                Connection conn = DriverManager.getConnection (strUrl, "user1", "********");
                Statement stmt = conn.createStatement();

                // create Vector responsemsg1 with meshmain,meshsub xml-string
                String mysql = "select distinct t3.cui " +
                                     "from hapiref as t1 " +
                                     "left join hapilit as t2 on t1.std_access = t2.std_access " +
                                     "left join hapimesh as t3 on t2.litui = t3.litui " +
                                     "where t1.accession = '" + spotid + "'";
                ResultSet result1 = stmt.executeQuery(mysql);
                // store resultset in Vector of Arrays
                   while (result1.next()) {
                        String[] rs = new String[] {result1.getString(1)};
                       mesh.add(rs);
                   }     
                   //close connection to database
                   stmt.close();
                   conn.close();           
               
              } catch (SQLException sqle1) {

                String errormsg = sqle1.getMessage();
                logHAPIdb.info( "Error: " + errormsg); //logging
                sb1 = MessageContext.getCurrentContext().getResponseMessage().getSOAPPart().getEnvelope().getBody(); // get SOAPBody
                SOAPFault fault = sb1.addFault();
                fault.setFaultString("Exception: " + errormsg);
                fault.setFaultCode("Server");
                throw sqle1;                 
                 
             } catch (Exception e1) {
                String errormsg = e1.getMessage();
                logHAPIdb.info( "Error: " + errormsg);
                sb1 = MessageContext.getCurrentContext().getResponseMessage().getSOAPPart().getEnvelope().getBody();
                SOAPFault fault = sb1.addFault();
                fault.setFaultString("Exception: " + errormsg);
                fault.setFaultCode("Server");
                throw e1;                 
              }
             
              // return resultset as Vector of Arrays
              return mesh;
        }

}


here's my code for the class where I create the SOAPFault:

Bhanu Pabreja wrote:
Remo,
Can you send me your code for the exception handler since I am unable to
make mine work and need some thing which is working and looks like u are
making a similar webservice (Message style).

Thanx.

dumdum420

-----Original Message-----
From: Bhanu Pabreja [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 10, 2003 12:30 PM
To: [EMAIL PROTECTED]
Subject: RE: Exception handling strategy question


the invoke() throws AxisFault ; this is what the api also shows. I am using
AXIS 1.1 and I also do not have a clue which SOAP level I am using.

Kindly clarify this. I have only one method exposed which is:
Document fetchData(Document dom){}

and I have clients which are going to be VB.Net based so tell me how should
I work on my error.

Also can you explain me more about the mandatory elements and values.

Send me the Handler and I will see if can put it in my evironment.

BP

-----Original Message-----
From: remko de knikker [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 10, 2003 9:38 AM
To: [EMAIL PROTECTED]
Subject: Re: Exception handling strategy question


Here's what I did:

Since the ..invoke() call throws a RemoteException
I used

... throws RemoteException {
try {
...
}
catch (RemoteException e1) {
            sb1 =
MessageContext.getCurrentContext().getResponseMessage().getSOAPPart().getEnv
elope().getBody();
            SOAPFault fault = sb1.addFault();
            fault.setFaultString("RemoteException: " + e1.getMessage());
            fault.setFaultCode("Client");
            throw e1;
}


Since I am using SOAP 1.1 which implements the SOAPFault codes
differently than SOAP 1.2
check to make sure which SOAP version you are using, because of
mandatory elements and values.
for SOAP 1.1:
http://www.w3.org/TR/SOAP/

I created a Handler, I can send the code if you want me to, but am not
doing anything with it, with regard to Exceptions, but you could of course.


Bhanu Pabreja wrote:

  
Well I saw this thread in the mail archive ... so got to ask a question.

Like remo i have a similar kind of service (message style) with only once
service operation exposed

Document fetchData(Document doc) throw AxisFault{}

Now Remo you must have implemented your exception handling already which
seems to be interoperatable as per your comments.

Can you please post me some sample code how you implemented the same.

Thanx a ton.

dumdum420.







    









  

Reply via email to