echo_impl_cb.cpp

来自「ESOAP是一款专注于嵌入式web service开发的工具 压缩包里提供了基」· C++ 代码 · 共 113 行

CPP
113
字号
/*
 Created by eSoap Code Generator for C++, >>> DEMO <<<  Version - 1.08
 **** DO NOT EDIT THIS FILE.  *****
 Time: Sun Sep 09 09:37:24 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 "Echo_impl.h"


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

namespace echo {

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

Echo_Impl::Echo_Impl()
 : __currentBlock( 0 )
{
}

Echo_Impl::~Echo_Impl()
{
}

void Echo_Impl::activate()
{
  typedef MemberCallback< esoap::MethodDataBlock, Echo_Impl > Echo_CB;
  struct Echo_MethodPair
  {
     const char *name;
     int (Echo_Impl::*member )(esoap::MethodDataBlock *);
  };

    static Echo_MethodPair listMethods[] =
  {
    { "echo", &Echo_Impl::echo_impl },
   };

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

}

void Echo_Impl::deactivate()
{
  typedef MemberCallback< esoap::MethodDataBlock, Echo_Impl > Echo_CB;
  struct Echo_MethodPair
  {
     const char *name;
     int (Echo_Impl::*member )(esoap::MethodDataBlock *);
  };

    static Echo_MethodPair listMethods[] =
  {
    { "echo", &Echo_Impl::echo_impl },
   };



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

int Echo_Impl::echo_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_i = mdata->in()->getRealParameter( m->getParameter( "i" ) );
  if( !l_i )
  {
    mdata->out()->setFault( esoap::Fault::Server,
                            "Missing Parameter = [i]" );
    return 0;
  }
  int i_i = l_i->getInteger();
  int o_return;
  o_return = echo( i_i );
  esoap::Method *resp = mdata->out()->setMethod( "m:echoResponse", NS_URI );
  resp->addInteger( "return", o_return );
  return 0;
}

}

⌨️ 快捷键说明

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