📄 interop.cpp
字号:
/////////////////////////////////////////////////////////////////////////////
// $Id: interop.cpp,v 1.8 2001/09/11 11:45:53 rosimildo Exp $
//
// Copyright (c) 2001 Exor International Inc. All rights reserved.
//
// MODULE DESCRIPTION:
// Callback entry points to implement the SOAP Interop test suite.
//
// MODIFICATION/HISTORY:
//
// $Log: interop.cpp,v $
// Revision 1.8 2001/09/11 11:45:53 rosimildo
// changed copyright from Technopoint to Exit; updated version to 0.9
//
// Revision 1.7 2001/05/14 19:13:36 rosimildo
// Fixed Must Understand handling
//
// Revision 1.6 2001/04/26 22:50:39 rosimildo
// Added version file -- made it 0.02.
//
// Revision 1.5 2001/04/26 03:13:39 rosimildo
// Initial debug of the TimeInstant and Binary.
// Added these methods to the interop test.
//
// Revision 1.4 2001/04/21 20:59:08 rosimildo
// Fixed spelling with the echoVoid.
//
// Revision 1.3 2001/04/20 13:13:35 rosimildo
// Completed tests with the CGI support.
//
// Revision 1.2 2001/04/19 17:30:26 rosimildo
// Added Support for CGI processes.
//
// Revision 1.1 2001/04/18 20:36:17 rosimildo
// cleanup Doxygen comments + adde interop server module
//
//
// Created 2001/02/08 Rosimildo da Silva, ConnectTel Inc.
// [rdasilva@connecttel.com]
//
/////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <assert.h>
#include "soap_server.h"
#include "soap_envelope.h"
#include "syslogpp.h"
/* must be the last include */
#ifdef MEMWATCH
#include <memwatch.h>
#endif
static const char *INTEROP_NS_URI = "http://soapinterop.org/";
/**
* Receives one string and echoes it back to the caller.
*/
int echoString( esoap::MethodDataBlock *mdata )
{
SYSLOG( "Method: echoString()\n" );
// let's access the parameters...
esoap::Method *m = mdata->in()->getMethod();
esoap::Parameter *p = m->getParameter( 0 );
// check if we have a parameter, and it is the only one
if( !p )
{
mdata->out()->setFault( esoap::Fault::Server, "ERROR: missing input string" );
return 0;
}
// check if it is the only one
if( m->getParameterCount() > 1 )
{
mdata->out()->setFault( esoap::Fault::Server,
"ERROR: too many parameters =%d", m->getParameterCount() );
return 0;
}
// seems to be ok.
esoap::String s = p->getString();
esoap::Method *resp = mdata->out()->setMethod( "e:echoStringResponse", INTEROP_NS_URI );
resp->addString( "outputString", s.c_str() );
return 0;
}
/**
* Receives one integer and echoes it back to the caller.
*/
int echoInteger( esoap::MethodDataBlock *mdata )
{
SYSLOG( "Method: echoInteger()\n" );
// let's access the parameters...
esoap::Method *m = mdata->in()->getMethod();
esoap::Parameter *p = m->getParameter( 0 );
// check if we have a parameter, and it is the only one
if( !p )
{
mdata->out()->setFault( esoap::Fault::Server, "ERROR: missing input integer" );
return 0;
}
// check if it is the only one
if( m->getParameterCount() > 1 )
{
mdata->out()->setFault( esoap::Fault::Server,
"ERROR: too many parameters =%d", m->getParameterCount() );
return 0;
}
// seems to be ok.
int i = p->getInteger();
esoap::Method *resp = mdata->out()->setMethod( "e:echoIntegerResponse", INTEROP_NS_URI );
resp->addInteger( "outputInteger", i );
return 0;
}
/**
* Receives one float and echoes it back to the caller.
*/
int echoFloat( esoap::MethodDataBlock *mdata )
{
SYSLOG( "Method: echoFloat()\n" );
// let's access the parameters...
esoap::Method *m = mdata->in()->getMethod();
esoap::Parameter *p = m->getParameter( 0 );
// check if we have a parameter, and it is the only one
if( !p )
{
mdata->out()->setFault( esoap::Fault::Server, "ERROR: missing input float" );
return 0;
}
// check if it is the only one
if( m->getParameterCount() > 1 )
{
mdata->out()->setFault( esoap::Fault::Server,
"ERROR: too many parameters =%d", m->getParameterCount() );
return 0;
}
// seems to be ok.
float f = p->getFloat();
esoap::Method *resp = mdata->out()->setMethod( "e:echoFloatResponse", INTEROP_NS_URI );
resp->addFloat( "outputFloat", f );
return 0;
}
/**
* Receives a void call ( no parameters ).
*/
int echoVoid( esoap::MethodDataBlock *mdata )
{
SYSLOG( "Method: echoVoid()\n" );
// let's access the parameters...
esoap::Method *m = mdata->in()->getMethod();
esoap::Parameter *p = m->getParameter( 0 );
// check if we have a parameter, and it is the only one
if( p )
{
mdata->out()->setFault( esoap::Fault::Server,
"ERROR: too many parameters =%d", m->getParameterCount() );
return 0;
}
mdata->out()->setMethod( "e:echoVoidResponse", INTEROP_NS_URI );
return 0;
}
/**
* Receives one array of string and echoes it back to the caller.
*/
int echoStringArray( esoap::MethodDataBlock *mdata )
{
SYSLOG( "Method: echoStringArray()\n" );
// let's access the parameters...
esoap::Method *m = mdata->in()->getMethod();
esoap::Parameter *p = mdata->in()->getRealParameter( m->getParameter( 0 ) );
// check if we have a parameter, and it is the only one
if( !p )
{
mdata->out()->setFault( esoap::Fault::Server, "ERROR: missing input Array of strings" );
return 0;
}
// check if it is the only one
if( m->getParameterCount() > 1 )
{
mdata->out()->setFault( esoap::Fault::Server,
"ERROR: too many parameters =%d", m->getParameterCount() );
return 0;
}
// check if it is array....
if( p->getType() != esoap::xsd_array )
{
mdata->out()->setFault( esoap::Fault::Server,
"ERROR: type is not array =%d", p->getType() );
return 0;
}
// send array back.
esoap::Method *resp = mdata->out()->setMethod( "e:echoStringArrayResponse", INTEROP_NS_URI );
esoap::Array *a = new esoap::Array( "outputStringArray" );
for( size_t i = 0; i < p->getParameterCount(); i++ )
{
esoap::Parameter *param = p->getParameter( i );
esoap::String s = param->getString();
a->addString( s.c_str() );
}
a->setType( esoap::xsd_string );
resp->addParameter( a );
return 0;
}
/**
* Receives one array of int and echoes it back to the caller.
*/
int echoIntegerArray( esoap::MethodDataBlock *mdata )
{
SYSLOG( "Method: echoIntegerArray()\n" );
// let's access the parameters...
esoap::Method *m = mdata->in()->getMethod();
esoap::Parameter *p = mdata->in()->getRealParameter( m->getParameter( 0 ) );
// check if we have a parameter, and it is the only one
if( !p )
{
mdata->out()->setFault( esoap::Fault::Server, "ERROR: missing input Array of integers" );
return 0;
}
// check if it is the only one
if( m->getParameterCount() > 1 )
{
mdata->out()->setFault( esoap::Fault::Server,
"ERROR: too many parameters =%d", m->getParameterCount() );
return 0;
}
// check if it is array....
if( p->getType() != esoap::xsd_array )
{
mdata->out()->setFault( esoap::Fault::Server,
"ERROR: type is not array =%d", p->getType() );
return 0;
}
// send array back.
esoap::Method *resp = mdata->out()->setMethod( "e:echoIntegerArrayResponse", INTEROP_NS_URI );
esoap::Array *a = new esoap::Array( "outputIntegerArray" );
for( size_t i = 0; i < p->getParameterCount(); i++ )
{
esoap::Parameter *param = p->getParameter( i );
int k = param->getInteger();
a->addInteger( k );
}
a->setType( esoap::xsd_int );
resp->addParameter( a );
return 0;
}
/**
* Receives one array of int and echoes it back to the caller.
*/
int echoFloatArray( esoap::MethodDataBlock *mdata )
{
SYSLOG( "Method: echoFloatArray()\n" );
// let's access the parameters...
esoap::Method *m = mdata->in()->getMethod();
esoap::Parameter *p = mdata->in()->getRealParameter( m->getParameter( 0 ) );
// check if we have a parameter, and it is the only one
if( !p )
{
mdata->out()->setFault( esoap::Fault::Server, "ERROR: missing input Array of floats" );
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -