⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addtwo_impl_cb.cpp

📁 ESOAP是一款专注于嵌入式web service开发的工具 压缩包里提供了基本的例子
💻 CPP
字号:
/*
 Created by eSoap Code Generator for C++, >>> DEMO <<<  Version - 1.08
 **** DO NOT EDIT THIS FILE.  *****
 Time: Mon Sep 17 19:55:10 2001

 **** CODE CREATED USING AN UNREGISTERED VERSION OF ESOAPCG.
 Please, after the initial testing, you *MUST* buy a
 copy of this application to continue using it.

 * Limits of this version:

     + 5 functions per interface
     + 5 User defined types( Complex Types )

*/

#include <assert.h>
#include "soap_server.h"
#include "soap_envelope.h"
#include "AddTwo_impl.h"


/* must be the last include */
#ifdef MEMWATCH
#include <memwatch.h>
#endif

namespace sample {

const char *AddTwo_Impl::NS_URI = "http://tempuri.com/";

AddTwo_Impl::AddTwo_Impl()
 : __currentBlock( 0 )
{
}

AddTwo_Impl::~AddTwo_Impl()
{
}

void AddTwo_Impl::activate()
{
  typedef MemberCallback< esoap::MethodDataBlock, AddTwo_Impl > AddTwo_CB;
  struct AddTwo_MethodPair
  {
     const char *name;
     int (AddTwo_Impl::*member )(esoap::MethodDataBlock *);
  };

    static AddTwo_MethodPair listMethods[] =
  {
    { "add", &AddTwo_Impl::add_impl },
   };

  
  for( int i = 0; i < sizeof( listMethods ) / sizeof( listMethods[ 0 ] ); i++ )
  {
     AddTwo_CB *mc = new AddTwo_CB( listMethods[i].member, this );
     esoap::Server::instance()->getRegistry().addMethod( listMethods[i].name, mc );
  }

}

void AddTwo_Impl::deactivate()
{
  typedef MemberCallback< esoap::MethodDataBlock, AddTwo_Impl > AddTwo_CB;
  struct AddTwo_MethodPair
  {
     const char *name;
     int (AddTwo_Impl::*member )(esoap::MethodDataBlock *);
  };

    static AddTwo_MethodPair listMethods[] =
  {
    { "add", &AddTwo_Impl::add_impl },
   };



  for( int i = 0; i < sizeof( listMethods ) / sizeof( listMethods[ 0 ] ); i++ )
  {
     esoap::Server::instance()->getRegistry().removeMethod(listMethods[i].name );
  }
}

int AddTwo_Impl::add_impl( esoap::MethodDataBlock *mdata )
{
  __currentBlock   = mdata;
  esoap::Method *m = mdata->in()->getMethod();
  if( !m )
  {
    mdata->out()->setFault( esoap::Fault::Server,
                            "Missing method element" );
    return 0;
  }

  esoap::Parameter *l_a = mdata->in()->getRealParameter( m->getParameter( "a" ) );
  if( !l_a )
  {
    mdata->out()->setFault( esoap::Fault::Server,
                            "Missing Parameter = [a]" );
    return 0;
  }
  int i_a = l_a->getInteger();
  esoap::Parameter *l_b = mdata->in()->getRealParameter( m->getParameter( "b" ) );
  if( !l_b )
  {
    mdata->out()->setFault( esoap::Fault::Server,
                            "Missing Parameter = [b]" );
    return 0;
  }
  int i_b = l_b->getInteger();
  int o_sum;
  o_sum = add( i_a, i_b );
  esoap::Method *resp = mdata->out()->setMethod( "m:addResponse", NS_URI );
  resp->addInteger( "sum", o_sum );
  return 0;
}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -