You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by da...@apache.org on 2004/05/13 14:20:30 UTC

cvs commit: ws-axis/c/samples/server/rpcfault MathOps.wsdl MathOps.cpp MathOps.h MathOpsWrapper.cpp MathOpsWrapper.h MathOpsService.cpp

damitha     2004/05/13 05:20:30

  Added:       c/samples/server/rpcfault MathOps.wsdl MathOps.cpp MathOps.h
                        MathOpsWrapper.cpp MathOpsWrapper.h
                        MathOpsService.cpp
  Log:
  fault mapping related stuff
  
  Revision  Changes    Path
  1.1                  ws-axis/c/samples/server/rpcfault/MathOps.wsdl
  
  Index: MathOps.wsdl
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <wsdl:definitions targetNamespace="http://localhost/axis/MathOps" 
  xmlns="http://schemas.xmlsoap.org/wsdl/" 
  xmlns:apachesoap="http://xml.apache.org/xml-soap"
  xmlns:impl="http://localhost/axis/MathOps"
  xmlns:intf="http://localhost/axis/MathOps"
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
  xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:s="http://soapinterop.org/xsd">
  <types>
      <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
          targetNamespace="http://soapinterop.org/xsd">
          <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
          <complexType name="SOAPStruct">
              <sequence>
                  <element name="varString" type="xsd:string"/>
                  <element name="varInt" type="xsd:int"/>
                  <element name="varFloat" type="xsd:float"/>
              </sequence>
          </complexType>
          <complexType name="SOAPStructFault">
              <sequence>
                  <element name="soapStruct" type="tns:SOAPStruct"/>
              </sequence>
          </complexType>
      </schema>
  
      <wsdl:message name="divRequest">
          <wsdl:part name="in0" type="xsd:int"/>
          <wsdl:part name="in1" type="xsd:int"/>
      </wsdl:message>
      <wsdl:message name="divResponse">
          <wsdl:part name="addReturn" type="xsd:int"/>
      </wsdl:message>
      <message name="SOAPStructFault">
          <part name="part1" type="s:SOAPStructFault"/>
      </message>
      <wsdl:portType name="MathOps">
          <wsdl:operation name="div" parameterOrder="in0 in1">
              <wsdl:input message="intf:divRequest" name="divRequest"/>
              <wsdl:output message="intf:divResponse" name="divResponse"/>
              <fault name="DivByZeroFault" message="tns:SOAPStructFault"/>
          </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="MathOpsSoapBinding" type="intf:MathOps">
          <wsdlsoap:binding style="rpc"
          transport="http://schemas.xmlsoap.org/soap/http"/>
  
          <wsdl:operation name="div">
              <wsdlsoap:operation soapAction="MathOps#div"/>
                  <wsdl:input name="divRequest">
                      <wsdlsoap:body 
                          encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
                          namespace="http://localhost/axis/MathOps" 
                          use="encoded"/>
                  </wsdl:input>
                  <wsdl:output name="divResponse">
                      <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
                          namespace="http://localhost/axis/MathOps" 
                          use="encoded"/>
                  </wsdl:output>
                  <fault name="ComplexFault">
                      <soap:fault name="DivByZeroFault" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                          namespace="http://soapinterop.org/wsdl"/>
                  </fault>
          </wsdl:operation>
      </wsdl:binding>  
      <wsdl:service name="MathOps">
          <wsdl:port binding="intf:MathOpsSoapBinding" name="MathOps">
              <wsdlsoap:address location="http://localhost/axis/MathOps"/>
          </wsdl:port>
      </wsdl:service>
  </wsdl:definitions>
  
  
  
  1.1                  ws-axis/c/samples/server/rpcfault/MathOps.cpp
  
  Index: MathOps.cpp
  ===================================================================
  /*
   *This is the Service implementation CPP file genarated by theWSDL2Ws.
   *		MathOps.cpp: implemtation for the MathOps.
   *
   */
  #include "MathOps.h"
  
  
  MathOps::MathOps()
  {
  }
  
  MathOps::~MathOps()
  {
  }
  
  int MathOps::div(int Value0, int Value1)
  {
  	if (Value1 == 0) return -1; /* :)) */
  	return Value0/Value1;
  }
  
  
  
  1.1                  ws-axis/c/samples/server/rpcfault/MathOps.h
  
  Index: MathOps.h
  ===================================================================
  /*
   * This is the Service Class genarated by the tool WSDL2Ws
   * MathOps.h: interface for the MathOps class.
   *
   */
  #if !defined(__MATHOPS_SERVERSKELETON_H__OF_AXIS_INCLUDED_)
  #define __MATHOPS_SERVERSKELETON_H__OF_AXIS_INCLUDED_
  
  #include <axis/server/AxisUserAPI.h>
  
  
  class MathOps 
  {
  	public:
  		MathOps();
  	public:
  		virtual ~MathOps();
  	public: 
  		int add(int Value0,int Value1);
  		int sub(int Value0,int Value1);
  		int mul(int Value0,int Value1);
  		int div(int Value0,int Value1);
  };
  
  #endif /* !defined(__CALCULATOR_SERVERSKELETON_H__OF_AXIS_INCLUDED_)*/
  
  
  
  1.1                  ws-axis/c/samples/server/rpcfault/MathOpsWrapper.cpp
  
  Index: MathOpsWrapper.cpp
  ===================================================================
  /*
   * This is the Service implementation CPP file genarated by theWSDL2Ws.
   * MathOpsWrapper.cpp: implemtation for the MathOpsWrapper.
   * 
   */
  
  #include "MathOpsWrapper.h"
  
  MathOpsWrapper::MathOpsWrapper()
  {
  	pWs = new MathOps();
  }
  
  MathOpsWrapper::~MathOpsWrapper()
  {
  	delete pWs;
  }
  
  /*implementation of WrapperClassHandler interface*/
  void MathOpsWrapper::onFault(void *pMsg)
  {
  }
  
  int MathOpsWrapper::init()
  {
  	return AXIS_SUCCESS;
  }
  
  int MathOpsWrapper::fini()
  {
  	return AXIS_SUCCESS;
  }
  
  
  /*
   * This method invokes the right service method 
   */
  int MathOpsWrapper::invoke(void *pMsg)
  {
  	IMessageData* mc = (IMessageData*)pMsg;
  	const AxisChar *method = mc->getOperationName();
  	if (0 == strcmp(method, "add"))
  		return add(mc);
  	else if (0 == strcmp(method, "sub"))
  		return sub(mc);
  	else if (0 == strcmp(method, "mul"))
  		return mul(mc);
  	else if (0 == strcmp(method, "div"))
  		return div(mc);
  	else return AXIS_FAIL;
  }
  
  
  /*Methods corresponding to the web service methods*/
  
  /*
   * This method wrap the service method 
   */
  int MathOpsWrapper::div(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("div", "http://localhost/axis/MathOps")) return AXIS_FAIL;
  	pIWSSZ->createSoapMethod("divResponse", "http://localhost/axis/MathOps");
  	int v0 = pIWSDZ->getElementAsInt("in0",0);
  	int v1 = pIWSDZ->getElementAsInt("in1",0);
  	if (AXIS_SUCCESS != (nStatus = pIWSDZ->getStatus())) return nStatus;
  	int ret = pWs->div(v0,v1);
  	return pIWSSZ->addOutputParam("divReturn", (void*)&ret, XSD_INT);
  }
  
  
  
  
  1.1                  ws-axis/c/samples/server/rpcfault/MathOpsWrapper.h
  
  Index: MathOpsWrapper.h
  ===================================================================
  /*
   * This is the Service Class genarated by the tool WSDL2Ws
   *		MathOpsWrapper.h: interface for the MathOpsWrapper class.
   *
   */
  #if !defined(__MATHOPSWRAPPER_SERVERWRAPPER_H__OF_AXIS_INCLUDED_)
  #define __MATHOPSWRAPPER_SERVERWRAPPER_H__OF_AXIS_INCLUDED_
  
  #include "MathOps.h"
  #include <axis/server/WrapperClassHandler.h>
  #include <axis/server/IMessageData.h>
  #include <axis/server/GDefine.h>
  #include <axis/server/AxisWrapperAPI.h>
  
  class MathOpsWrapper : public WrapperClassHandler
  {
  private:/* Actual web service object*/
  	MathOps *pWs;
  public:
  	MathOpsWrapper();
  public:
  	virtual ~MathOpsWrapper();
  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 div(void* pMsg);
  };
  
  #endif /* !defined(__CALCULATORWRAPPER_SERVERWRAPPER_H__OF_AXIS_INCLUDED_)*/
  
  
  
  1.1                  ws-axis/c/samples/server/rpcfault/MathOpsService.cpp
  
  Index: MathOpsService.cpp
  ===================================================================
  /*This file is automatically generated by the Axis C++ Wrapper Class Generator
   *Service file containing the two export functions of the Web service Library*/
  #ifdef WIN32
  #define STORAGE_CLASS_INFO __declspec(dllexport)
  #else
  #define STORAGE_CLASS_INFO 
  #endif
  #include "MathOpsWrapper.h" 
  extern "C" {
  STORAGE_CLASS_INFO
  int GetClassInstance(BasicHandler **inst)
  {
  	*inst = new BasicHandler();
  	WrapperClassHandler* pWCH = new MathOpsWrapper();
  	(*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;
  }
  }