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

📄 echo_impl_cb.cpp

📁 ESOAP是一款专注于嵌入式web service开发的工具 压缩包里提供了基本的例子
💻 CPP
字号:
/*
 Created by eSoap Code Generator for C++, >>> DEMO <<<  Version - 1.08
 **** DO NOT EDIT THIS FILE.  *****
 Time: Sun Sep 09 09:37:42 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_user = mdata->in()->getRealParameter( m->getParameter( "user" ) );
  if( !l_user )
  {
    mdata->out()->setFault( esoap::Fault::Server,
                            "Missing Parameter = [user]" );
    return 0;
  }
  UserProfile i_user;
  if( !i_user.from( l_user, mdata->in() ) )
  {
    // delete i_user;
    mdata->out()->setFault( esoap::Fault::Server,
                   "Missing Parameter = [user]" );
    return 0;
  }
  esoap::String o_name;
  int o_age;
  int o_zipcode;
  echo( i_user, o_name, o_age, o_zipcode );
  esoap::Method *resp = mdata->out()->setMethod( "m:echoResponse", NS_URI );
  resp->addString( "name", o_name );
  resp->addInteger( "age", o_age );
  resp->addInteger( "zipcode", o_zipcode );
  mdata->out()->addAttribute( "xmlns:ns1", "http://tempuri.com/xsd" );
  return 0;
}

}

⌨️ 快捷键说明

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