axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject cvs commit: ws-axis/c/samples/client/rpcfault AxisDivByZeroException.cpp AxisDivByZeroException.h
Date Mon, 24 May 2004 05:46:28 GMT
damitha     2004/05/23 22:46:28

  Added:       c/include/axis/server AxisMessage.h
               c/src/common AxisMessage.cpp
               c/samples/client/rpcfault AxisDivByZeroException.cpp
                        AxisDivByZeroException.h
  Log:
  fault mapping and exception handling related work
  
  Revision  Changes    Path
  1.1                  ws-axis/c/include/axis/server/AxisMessage.h
  
  Index: AxisMessage.h
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   *
   *
   *   @author Damitha Kumarage (damitha@opensource.lk, damitha@jkcsworld.com)
   *
   */
   
  #ifndef __AXISMESSAGE_H_OF_AXIS_INCLUDED_
  #define __AXISMESSAGE_H_OF_AXIS_INCLUDED_
  
  #include <string>
  #include "AxisException.h"
  
  using namespace std;
  
  class AxisMessage
  {
  
  public:
      AxisMessage(){};
      virtual ~AxisMessage(){};
      const string getMessage(int iExceptionCode);
  
  private:
      string m_sMessage;
      int m_iExceptionCode;
  };
  
  #endif
  
  
  
  
  1.1                  ws-axis/c/src/common/AxisMessage.cpp
  
  Index: AxisMessage.cpp
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   *
   *
   *   @author Damitha Kumarage (damitha@opensource.lk, damitha@jkcsworld.com)
   *
   */
   
  #include <axis/server/AxisMessage.h>
  
  const string AxisMessage::getMessage(int iExceptionCode)
  {
      switch(iExceptionCode)
      {
          case AXISC_SERVICE_THROWN_EXCEPTION:
              m_sMessage = "A service has thrown an exception. see detail";
              break;
          case SERVER_TESTEXCEPTION:
              m_sMessage = "This is a testing error";
              break;
          case AXISC_NODEVALUE_MISMATCH_EXCEPTION:
              m_sMessage = "Cannot deserialize the requested element";
              break;
          case SERVER_CONFIG_TRANSPORTCONFFAILED:
              m_sMessage = "Transport layer is not configured properly";
              break;
          case SERVER_CONFIG_LIBRARYPATHEMPTY:
              m_sMessage = "Library path is empty(Not in server.wsdd file)";
              break; 
          case SOAP_VERSIONMISMATCH :
              m_sMessage = "Soap Version mismatch fault occured";
              break;
          case SOAP_MUSTUNDERSTAND:
              m_sMessage = "Soap Must understand fault occured";
              break;
          case CLIENT_SOAP_MESSAGEINCOMPLETE:
              m_sMessage = "Received message is incomplete";
              break;
          case CLIENT_SOAP_SOAPACTIONEMTPY:
              m_sMessage = "Soap action is empty";
              break;
          case CLIENT_SOAP_SOAPCONTENTERROR:
              m_sMessage = "Received content is faulty";
              break;
          case CLIENT_SOAP_NOSOAPMETHOD:
              m_sMessage = "Request method is not a soap method";
              break; 
          case CLIENT_WSDD_SERVICENOTFOUND:
              m_sMessage = "Requested service not found";
              break;
          case CLIENT_WSDD_METHODNOTALLOWED:
              m_sMessage = "Requested method is not allowed";
              break;
          case CLIENT_WSDD_PARATYPEMISMATCH:
              m_sMessage = "Parameter type mismatch";
              break;
          case SERVER_WSDD_NOHANDLERSCONFIGURED:
              m_sMessage = "No handlers configured in server.wsdd";
              break;
          case SERVER_ENGINE_COULDNOTLOADSRV:
              m_sMessage = "Could not load service";
              break;
          case SERVER_ENGINE_COULDNOTLOADHDL:
              m_sMessage = "Could not load handler";
              break;
          case SERVER_ENGINE_HANDLERFAILED:
              m_sMessage = "Handler failed";
              break;
          case SERVER_ENGINE_WEBSERVICEFAILED:
              m_sMessage = "Web Service failed";
              break;
          case SERVER_ENGINE_HANDLERINITFAILED:
              m_sMessage = "Handler initialization failed";
              break;
          case SERVER_ENGINE_HANDLERCREATIONFAILED:
              m_sMessage = "Handler creation failed";
              break;
          case SERVER_ENGINE_LIBRARYLOADINGFAILED:
              m_sMessage = "Library loading failed";
              break;
          case SERVER_ENGINE_HANDLERNOTLOADED:
              m_sMessage = "Handler is not loaded";
              break;
          case SERVER_ENGINE_HANDLERBEINGUSED:
              m_sMessage = "Handler is being used";
              break;
          case SERVER_ENGINE_GETHANDLERFAILED:
              m_sMessage = "Get handler failed"; 
              break;
          case SERVER_ENGINE_WRONGHANDLERTYPE:
              m_sMessage = "Wrong handler type";
              break;
          case SERVER_TRANSPORT_RECEPTIONEXCEPTION:
              m_sMessage = "Problem occured when receiving the stream";
              break;
          case SERVER_TRANSPORT_SENDINGEXCEPTION:
              m_sMessage = "Problem occured when sending the stream";
              break;
          case SERVER_TRANSPORT_HTTP_EXCEPTION:
              m_sMessage = "HTTP transport error";
              break;
  
          default:
              m_sMessage = "Unknown Exception has occured";
  
      }
      return m_sMessage;
  }
  
  
  
  
  1.1                  ws-axis/c/samples/client/rpcfault/AxisDivByZeroException.cpp
  
  Index: AxisDivByZeroException.cpp
  ===================================================================
  /* -*- C++ -*- */
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   *
   * 
   * @author  wsdl2ws generated
   *
   */
  
  #include "AxisDivByZeroException.h"
  #include <exception>
  using namespace std;
  
  /**
   *    Default when no parameter passed. When thrown with no parameter
   *    more general AXISC_DIVBYZERO_EXCEPTION is assumed.
  */
  
  AxisDivByZeroException::AxisDivByZeroException()
  {
      /* This only serves the pupose of indicating that the 
       * service has thrown an excpetion
       */
      m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION;
      processException(m_iExceptionCode);
  }
  
  AxisDivByZeroException::AxisDivByZeroException(SOAPStructFault* pFault)
  {
      m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION;
      processException(pFault);
  }
  
  AxisDivByZeroException::AxisDivByZeroException (int iExceptionCode)
  {
      m_iExceptionCode = iExceptionCode;
      processException (iExceptionCode);
  }
  
  AxisDivByZeroException::AxisDivByZeroException (exception* e)
  {
      processException (e);
  }
  
  AxisDivByZeroException::AxisDivByZeroException (exception* e, int iExceptionCode)
  {
      processException (e, iExceptionCode);
  }
  
  AxisDivByZeroException::~AxisDivByZeroException() throw ()
  {
          m_sMessage = "";
  }
  
  void AxisDivByZeroException::processException (exception* e, int iExceptionCode)
  {
      m_sMessage = getMessage (e) + getMessage (iExceptionCode);
  }
  
  void AxisDivByZeroException::processException (SOAPStructFault* pFault)
  {
      /*start user code*/
      int iSize = strlen(pFault->varString) + 8;
      char* sMessage = (char*) malloc(iSize);
      m_sMessage = (char*) malloc(iSize);
      char carrTempBuff[4];
      sprintf(carrTempBuff, "%d", pFault->varInt);
      strcat(sMessage, carrTempBuff);
      strcat(sMessage, "\n");
      sprintf(carrTempBuff, "%f", pFault->varFloat);
      strcat(sMessage, carrTempBuff);
      strcat(sMessage, "\n");
      strcat(sMessage, pFault->varString);
      strcat(sMessage, "\n");
      m_sMessage = sMessage;
      free(sMessage);
      /*end user code*/
  }
  
  void AxisDivByZeroException::processException (exception* e)
  {
      m_sMessage = getMessage (e);
  }
  
  void AxisDivByZeroException::processException(int iExceptionCode)
  {
      m_sMessage = getMessage (iExceptionCode);
  }
  
  const string AxisDivByZeroException::getMessage (exception* objException)
  {
      string sMessage = objException->what();
  
      return sMessage;
  }
  
  const string AxisDivByZeroException::getMessage (int iExceptionCode)
  {
      string sMessage;
      switch(iExceptionCode)
      {
          case AXISC_SERVICE_THROWN_EXCEPTION:
              sMessage = "A service has thrown an exception. see detail";
              break;
          default:
              sMessage = "Unknown Exception has occured";
      }
      return sMessage;
  }
  
  const char* AxisDivByZeroException::what() throw ()
  {
      return m_sMessage.c_str ();
  }
  
  const int AxisDivByZeroException::getExceptionCode()
  {
      return m_iExceptionCode;
  }
  
  
  
  
  1.1                  ws-axis/c/samples/client/rpcfault/AxisDivByZeroException.h
  
  Index: AxisDivByZeroException.h
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   *
   *
   *   @author wsdl2ws generated
   *
   */
   
  #ifndef __AXISDIVBYZEROEXCEPTION_H_OF_AXIS_INCLUDED_
  #define __AXISDIVBYZEROEXCEPTION_H_OF_AXIS_INCLUDED_
  
  #include <string>
  #include <exception>
  #include <axis/server/AxisException.h>
  #include "SOAPStructFault.h"
  
  using namespace std;
  
  class AxisDivByZeroException : public AxisException
  {
  
  public:
      AxisDivByZeroException();
      AxisDivByZeroException(SOAPStructFault* pFault);
      AxisDivByZeroException(int iExceptionCode);
      AxisDivByZeroException(exception* e);
      AxisDivByZeroException(exception* e, int iExceptionCode);
      virtual ~AxisDivByZeroException() throw();
      const char* what() throw();
      const int getExceptionCode();
      const string getMessage(exception* e);
      const string getMessage(int iExceptionCode);
                                                                                         
                                     
  private:
      void processException(exception* e);
      void processException(SOAPStructFault* pFault);
      void processException(exception* e, int iExceptionCode);
      void processException(int iExceptionCode);
      string m_sMessage;
      int m_iExceptionCode;
  };
  
  #endif
  
  
  
  

Mime
View raw message