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/18 13:12:45 UTC
cvs commit: ws-axis/c/samples/client/simple MathOps.cpp MathOps.h MathOpsClient.cpp Makefile.am
damitha 2004/05/18 04:12:45
Modified: c/samples/client/simple Makefile.am
Added: c/samples/client/simple MathOps.cpp MathOps.h
MathOpsClient.cpp
Log:
Revision Changes Path
1.4 +3 -5 ws-axis/c/samples/client/simple/Makefile.am
Index: Makefile.am
===================================================================
RCS file: /home/cvs/ws-axis/c/samples/client/simple/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Makefile.am 10 May 2004 04:21:09 -0000 1.3
+++ Makefile.am 18 May 2004 11:12:45 -0000 1.4
@@ -1,8 +1,6 @@
-bin_PROGRAMS = calculator
+bin_PROGRAMS = mathops
SUBDIRS =
AM_CPPFLAGS = $(CPPFLAGS)
-calculator_SOURCES = Calculator.cpp CalcClient.cpp
-
-#calculator_LDADD = $(LDFLAGS) -L$(AXISCPP_HOME)/bin -laxiscpp_client -ldl
-calculator_LDADD = $(LDFLAGS)
+mathops_SOURCES = MathOps.cpp MathOpsClient.cpp
+mathops_LDADD = $(LDFLAGS)
INCLUDES = -I$(AXISCPP_HOME)/include
1.1 ws-axis/c/samples/client/simple/MathOps.cpp
Index: MathOps.cpp
===================================================================
/*
* This is the Client Stub implementation file genarated by WSDL2Ws tool.
* MathOps.cpp: implemtation for the MathOps.
*
*/
#include "MathOps.h"
#include <axis/server/AxisWrapperAPI.h>
bool CallBase::bInitialized;
CallFunctions CallBase::ms_VFtable;
MathOps::MathOps(const char* pchEndpointUri)
{
m_pCall = new Call();
m_pCall->setProtocol(APTHTTP);
m_pCall->setEndpointURI(pchEndpointUri);
}
MathOps::~MathOps()
{
delete m_pCall;
}
/*Methods corresponding to the web service methods*/
/*
* This method wrap the service methoddiv
*/
int MathOps::div(int Value0, int Value1)
{
int Ret;
if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER, NORMAL_CHANNEL)) return Ret;
m_pCall->setTransportProperty(SOAPACTION_HEADER , "MathOps#div");
m_pCall->setSOAPVersion(SOAP_VER_1_1);
m_pCall->setOperation("div", "http://localhost/axis/MathOps");
m_pCall->addParameter((void*)&Value0, "in0", XSD_INT);
m_pCall->addParameter((void*)&Value1, "in1", XSD_INT);
if (AXIS_SUCCESS == m_pCall->invoke())
{
if(AXIS_SUCCESS == m_pCall->checkMessage("divResponse", "http://localhost/axis/MathOps"))
{
Ret = m_pCall->getElementAsInt("addReturn", 0);
}
}
m_pCall->unInitialize();
return Ret;
}
int MathOps::getFaultDetail(char** ppcDetail)
{
m_pCall->getFaultDetail(ppcDetail);
}
1.1 ws-axis/c/samples/client/simple/MathOps.h
Index: MathOps.h
===================================================================
/*
* This is the Client Stub Class genarated by the tool WSDL2Ws
* MathOps.h: interface for the MathOpsclass.
*
*/
#if !defined(__MATHOPS_CLIENTSTUB_H__OF_AXIS_INCLUDED_)
#define __MATHOPS_CLIENTSTUB_H__OF_AXIS_INCLUDED_
#include <axis/client/Call.h>
#include <ctype.h>
class MathOps
{
private:
Call* m_pCall;
public:
MathOps(const char* pchEndpointUri);
public:
virtual ~MathOps();
public:
int div(int Value0,int Value1);
int getFaultDetail(char** ppcDetail);
};
#endif /* !defined(__MATHOPS_CLIENTSTUB_H__OF_AXIS_INCLUDED_)*/
1.1 ws-axis/c/samples/client/simple/MathOpsClient.cpp
Index: MathOpsClient.cpp
===================================================================
#include "MathOps.h"
void PrintUsage();
bool IsNumber(const char* p);
int main(int argc, char* argv[])
{
char endpoint[256];
const char* server="localhost";
const char* port="80";
const char* op = 0;
const char* p1 = 0;
const char* p2 = 0;
int i1=0, i2=0;
int iResult;
char* pcDetail;
if (argc < 6)
{
PrintUsage();
}
else
{
server = argv[1];
port = argv[2];
}
printf("Sending Requests to Server http://%s:%s ........\n\n", server, port);
sprintf(endpoint, "http://%s:%s/axis/MathOps", server, port);
MathOps ws(endpoint);
op = argv[3];
p1 = argv[4];
p2 = argv[5];
if (!IsNumber(p1))
{
printf("Invalid value for first <parameter>\n\n");
PrintUsage();
}
if (!IsNumber(p2))
{
printf("Invalid value for second <parameter>\n\n");
PrintUsage();
}
i1 = atoi(p1);
i2 = atoi(p2);
if (strcmp(op, "div") == 0)
{
iResult = ws.div(i1, i2);
}
else
{
printf("Invalid operation %s\n\n", op);
PrintUsage();
}
return 0;
}
void PrintUsage()
{
printf("Usage :\n MathOps <server> <port> <operation> <parameter> <parameter>\n\n");
exit(1);
}
bool IsNumber(const char* p)
{
for (int x=0; x < strlen(p); x++)
{
if (!isdigit(p[x])) return false;
}
return true;
}