You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ni...@apache.org on 2005/01/26 12:01:43 UTC

cvs commit: ws-axis/c/samples/server/mime AxisServiceException.cpp AxisServiceException.hpp Makefile.am pt1.cpp pt1.hpp pt1Service.cpp pt1Wrapper.cpp pt1Wrapper.hpp deploy.wsdd undeploy.wsdd

nithya      2005/01/26 03:01:43

  Added:       c/samples/server/mime AxisServiceException.cpp
                        AxisServiceException.hpp Makefile.am pt1.cpp
                        pt1.hpp pt1Service.cpp pt1Wrapper.cpp
                        pt1Wrapper.hpp deploy.wsdd undeploy.wsdd
  Log:
  sample to support ws-attachment
  
  Revision  Changes    Path
  1.1                  ws-axis/c/samples/server/mime/AxisServiceException.cpp
  
  Index: AxisServiceException.cpp
  ===================================================================
  /*
   * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
   * This file contains implementations of the Attachment Exception class of the web service.
   */
  
  #include "AxisServiceException.hpp"
  
  #include <axis/AxisWrapperAPI.hpp>
  
  AxisServiceException::AxisServiceException()
  {
  /* This only serves the purpose of indicating that the 
   * service has thrown an excpetion 
   */ 
  	m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION; 
  	processException(m_iExceptionCode); 
  }
  
  AxisServiceException::AxisServiceException(ISoapFault* pFault)
  {
  	m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION;
  	m_pISoapFault = pFault;
  	processException(pFault);}
  
  AxisServiceException::AxisServiceException(int iExceptionCode)
  {
  
  	m_iExceptionCode = iExceptionCode;
  	processException (iExceptionCode);
  }
  
  AxisServiceException::AxisServiceException(exception* e)
  {
  	processException (e);
  }
  
  AxisServiceException::AxisServiceException(exception* e,int iExceptionCode)
  {
  
  	processException (e, iExceptionCode);
  }
  
  AxisServiceException::AxisServiceException(string sMessage)
  {
  	 m_sMessage =sMessage;
  }
  
  AxisServiceException::~AxisServiceException() throw () 
  {
  	m_sMessage ="";
  }
  
  void AxisServiceException:: processException(exception* e, int iExceptionCode)
  {
  	m_sMessage = getMessage (e) + getMessage (iExceptionCode);
  }
  
  void AxisServiceException::processException (ISoapFault* pFault)
  {
  	/*User can do something like deserializing the struct into a string*/
  }
  
  void AxisServiceException::processException(exception* e)
  {
  	m_sMessage = getMessage (e);
  }
  
  void AxisServiceException::processException(int iExceptionCode)
  {
  	m_sMessage = getMessage (iExceptionCode);
  }
  
  const string AxisServiceException::getMessage (exception* objException)
  {
  	string sMessage = objException->what();
  	return sMessage;
  }
  
  const string AxisServiceException::getMessage (int iExceptionCode)
  {
  	string sMessage;
  	switch(iExceptionCode)
  	{
  		case AXISC_SERVICE_THROWN_EXCEPTION:
  		sMessage = "The Attachment service has thrown an exception. see details";
  		break;
  		default:
  		sMessage = "Unknown Exception has occured in the Attachment service";
  	}
  return sMessage;
  }
  
  const char* AxisServiceException::what() throw ()
  {
  	return m_sMessage.c_str ();
  }
  
  const int AxisServiceException::getExceptionCode(){
  	return m_iExceptionCode;
  }
  
  const ISoapFault* AxisServiceException::getFault(){
  	return m_pISoapFault;
  }
  
  
  
  
  1.1                  ws-axis/c/samples/server/mime/AxisServiceException.hpp
  
  Index: AxisServiceException.hpp
  ===================================================================
  /*
   * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
   * This file contains an Exception class of the web service.
   */
  
  #if !defined(__AXISSERVICEEXCEPTION_EXCEPTION_H__INCLUDED_)
  #define __AXISSERVICEEXCEPTION_EXCEPTION_H__INCLUDED_
  
  #include <string>
  #include <exception>
  #include <axis/AxisException.hpp>
  #include <axis/ISoapFault.hpp>
  using namespace std;
  AXIS_CPP_NAMESPACE_USE 
  
  class AxisServiceException: public AxisException
  {
  public:
  	STORAGE_CLASS_INFO AxisServiceException();
  	STORAGE_CLASS_INFO AxisServiceException(ISoapFault* pFault);
  	STORAGE_CLASS_INFO AxisServiceException(int iExceptionCode);
  	STORAGE_CLASS_INFO AxisServiceException(exception* e);
  	STORAGE_CLASS_INFO AxisServiceException(exception* e, int iExceptionCode);
  	STORAGE_CLASS_INFO AxisServiceException(string sMessage);
  	STORAGE_CLASS_INFO virtual ~AxisServiceException() throw();
  	STORAGE_CLASS_INFO const char* what() throw();
  	STORAGE_CLASS_INFO const int getExceptionCode();
  	STORAGE_CLASS_INFO const string getMessage(exception* e);
  	STORAGE_CLASS_INFO const string getMessage(int iExceptionCode);
  	STORAGE_CLASS_INFO const ISoapFault* getFault();
  
  private:
  	 void processException(exception* e);
  	 void processException(ISoapFault* pFault);
  	 void processException(exception* e, int iExceptionCode);
  	 void processException(int iExceptionCode);
  	 string m_sMessage;
  	 int m_iExceptionCode;
  	 ISoapFault* m_pISoapFault;
  
  };
  
  #endif /* !defined(__AXISSERVICEEXCEPTION_EXCEPTION_H__INCLUDED_)*/
  
  
  
  1.1                  ws-axis/c/samples/server/mime/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  lib_LTLIBRARIES = libmime.la
  SUBDIRS =
  libmime_la_SOURCES = AxisServiceException.cpp  pt1.cpp  pt1Service.cpp  pt1Wrapper.cpp 
  libmime_la_LIBADD  = $(LDFLAGS)
  INCLUDES = -I$(AXISCPP_HOME)/include
  
  
  
  
  
  
  1.1                  ws-axis/c/samples/server/mime/pt1.cpp
  
  Index: pt1.cpp
  ===================================================================
  /*
   * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
   * This file contains definitions of the web service
   */
  
  #include "pt1.hpp"
  
  
  pt1::pt1()
  {
  }
  
  pt1::~pt1()
  {
  }
  
  /* This function is called by the AxisEngine when something went wrong
   with the current web service request processing. Appropriate actions should
   be taken here.*/
  void pt1::onFault()
  {
  }
  /* This function is called by the AxisEngine when this web service
   library is first loaded. So here we can initialize any global/static
   data structures of this web service or open database connections */
  void pt1::init()
  {
  }
  /* This function is called by the AxisEngine when this web service
   library is unloaded. So we can deallocate any global/static data structures
   and close database connections etc here. */
  void pt1::fini()
  {
  }
  /*xsd__base64Binary pt1::EchoAttachment(xsd__base64Binary Value0)  
  {
  	return Value0;
  }
  */
  
  ISoapAttachment* pt1::EchoAttachment(ISoapAttachment* objSoapAttach)
  {
  	return objSoapAttach;
  }
  
  
  
  1.1                  ws-axis/c/samples/server/mime/pt1.hpp
  
  Index: pt1.hpp
  ===================================================================
  /*
   * This is the Service Class genarated by the tool WSDL2Ws
   * pt1.hpp: interface for the pt1class.
   *
   */
  #if !defined(__PT1_SERVERSKELETON_H__INCLUDED_)
  #define __PT1_SERVERSKELETON_H__INCLUDED_
  
  #include <axis/AxisUserAPI.hpp>
  #include "AxisServiceException.hpp" 
  #include <axis/ISoapAttachment.hpp>
  
  class pt1 
  {
  	public:
  		pt1();
  	public:
  		virtual ~pt1();
  	public: 
  		void onFault();
  		void init();
  		void fini();
  	    ISoapAttachment* EchoAttachment(ISoapAttachment* objSoapAttach);
  		//xsd__base64Binary EchoAttachment(xsd__base64Binary Value0);
  };
  
  
  #endif /* !defined(__PT1_SERVERSKELETON_H__INCLUDED_)*/
  
  
  
  1.1                  ws-axis/c/samples/server/mime/pt1Service.cpp
  
  Index: pt1Service.cpp
  ===================================================================
  /*
   * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
   * This file contains the two export functions of the Web service Dynamic Library 
   */
  
  #include "pt1Wrapper.hpp" 
  extern "C" {
  STORAGE_CLASS_INFO
  int GetClassInstance(BasicHandler **inst)
  {
  	*inst = new BasicHandler();
  	WrapperClassHandler* pWCH = new pt1Wrapper();
  	(*inst)->_functions = 0;
  	if (pWCH)
  	{
  		(*inst)->_object = pWCH;
  		return pWCH->init();
  	}
  	return AXIS_FAIL;
  }
  STORAGE_CLASS_INFO 
  int DestroyInstance(BasicHandler *inst)
  {
  	if (inst)
  	{
  		WrapperClassHandler* pWCH = reinterpret_cast<WrapperClassHandler*>(inst);
  		pWCH->fini();
  		delete pWCH;
  		delete inst;
  		return AXIS_SUCCESS;
  	}
  	return AXIS_FAIL;
  }
  }
  
  
  
  1.1                  ws-axis/c/samples/server/mime/pt1Wrapper.cpp
  
  Index: pt1Wrapper.cpp
  ===================================================================
  /*
   * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
   * This file contains Web Service Wrapper implementations
   */
  
  #include "pt1Wrapper.hpp"
  
  #include <axis/ISoapAttachment.hpp>
  
  pt1Wrapper::pt1Wrapper()
  {
  	pWs = new pt1();
  }
  
  pt1Wrapper::~pt1Wrapper()
  {
  	delete pWs;
  }
  
  /*implementation of WrapperClassHandler interface*/
  void pt1Wrapper::onFault(void *pMsg)
  {
  	pWs->onFault();
  }
  
  int pt1Wrapper::init()
  {
  	pWs->init();
  	return AXIS_SUCCESS;
  }
  
  int pt1Wrapper::fini()
  {
  	pWs->fini();
  	return AXIS_SUCCESS;
  }
  
  
  /*
   * This method invokes the right service method 
   */
  int pt1Wrapper::invoke(void *pMsg)
  {
  	IMessageData* mc = (IMessageData*)pMsg;
  	const AxisChar *method = mc->getOperationName();
  	if (0 == strcmp(method, "EchoAttachment"))
  		return EchoAttachment(mc);
  	else return AXIS_FAIL;
  }
  
  
  /*Methods corresponding to the web service methods*/
  
  /*
   * This method wrap the service method 
   */
  
  int pt1Wrapper::EchoAttachment(void* pMsg) {
      IMessageData* mc = (IMessageData*)pMsg;
  	int nStatus;
  	IWrapperSoapSerializer* pIWSSZ = NULL;
  	mc->getSoapSerializer(&pIWSSZ);
  	if (!pIWSSZ) return AXIS_FAIL;
  	IWrapperSoapDeSerializer* pIWSDZ = NULL;
  	mc->getSoapDeSerializer(&pIWSDZ);
  	if (!pIWSDZ) return AXIS_FAIL;
  	/* check whether we have got correct message */
      if (AXIS_SUCCESS != pIWSDZ->checkMessageBody("EchoAttachment", "urn:EchoAttachmentsService")) return AXIS_FAIL;	
  	pIWSSZ->createSoapMethod("EchoAttachmentResponse", "urn:EchoAttachmentsService");
  	xsd__string v0 = pIWSDZ->getElementAsString("id",0);
      ISoapAttachment* objSoapAttach = pIWSDZ->getAttachment(v0);
      
  	if (AXIS_SUCCESS != (nStatus = pIWSDZ->getStatus())) return nStatus;
  	try
  	{		
          ISoapAttachment* ret = pWs->EchoAttachment(objSoapAttach);
          pIWSSZ->addAttachment(v0, ret);		
          return pIWSSZ->addOutputParam("EchoAttachmentReturn", (void*)&v0, XSD_STRING);
  	}
  	catch(...){
  	}
  }
  
  
  
  1.1                  ws-axis/c/samples/server/mime/pt1Wrapper.hpp
  
  Index: pt1Wrapper.hpp
  ===================================================================
  /*
   * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
   * This file contains Web Service Wrapper declarations
   */
  
  #if !defined(__PT1WRAPPER_SERVERWRAPPER_H__INCLUDED_)
  #define __PT1WRAPPER_SERVERWRAPPER_H__INCLUDED_
  
  #include "pt1.hpp"
  #include <axis/server/WrapperClassHandler.hpp>
  #include <axis/IMessageData.hpp>
  #include <axis/GDefine.hpp>
  #include <axis/AxisWrapperAPI.hpp>
  #include "AxisServiceException.hpp" 
  AXIS_CPP_NAMESPACE_USE 
  
  class pt1Wrapper : public WrapperClassHandler
  {
  private:/* Actual web service object*/
  	pt1 *pWs;
  public:
  	pt1Wrapper();
  public:
  	virtual ~pt1Wrapper();
  public:/*implementation of WrapperClassHandler interface*/
  	int AXISCALL invoke(void* pMsg);
  	void AXISCALL onFault(void* pMsg);
  	int AXISCALL init();
  	int AXISCALL fini();
  	AXIS_BINDING_STYLE AXISCALL getBindingStyle(){return RPC_ENCODED;};
  private:/*Methods corresponding to the web service methods*/
  	int EchoAttachment(void* pMsg);
  };
  
  #endif /* !defined(__PT1WRAPPER_SERVERWRAPPER_H__INCLUDED_)*/
  
  
  
  1.1                  ws-axis/c/samples/server/mime/deploy.wsdd
  
  Index: deploy.wsdd
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:CPP="http://xml.apache.org/axis/wsdd/providers/CPP">
  	<service name="Attachment" provider="CPP:RPC" description="Axis C++ web service">
  		<parameter name="className" value="/user/local/apache/axis/Attachment.so"/>
  		<parameter name="allowedMethods" value="EchoAttachment "/>
  	</service>
  </deployment>
  
  
  
  1.1                  ws-axis/c/samples/server/mime/undeploy.wsdd
  
  Index: undeploy.wsdd
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <undeployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:CPP="http://xml.apache.org/axis/wsdd/providers/CPP">
  	<service name="Attachment"/>
  </undeployment>