Hello Gentle-people...
I am having issues running the axis-c++ distribution sample code.
I am attempting to compile Calculator but it won't even compile.
I am afraid I am not enough of a C++ maven to decypher the errors. From
what I can tell I am following the book.
Here is what I do on the command line:
[EMAIL PROTECTED]:[calculator]:[1300]> pwd
/home/cue/workbench/axis-c-1.5.0-linux-src/samples/client/calculator
[EMAIL PROTECTED]:[calculator]:[1301]> echo $AXISCPP_HOME/
/home/cue/workbench/axis-c-1.5.0-linux-src/
[EMAIL PROTECTED]:[calculator]:[1302]> ls
Calculator.cpp Calculator.hpp Client.cpp
[EMAIL PROTECTED]:[calculator]:[1303]> g++ *.cpp -I$AXISCPP_HOME/include
-L$AXISCPP_DEPLOY/lib -ldl -laxiscpp_client -ocalculator
/usr/bin/ld: cannot find -laxiscpp_client
collect2: ld returned 1 exit status
[EMAIL PROTECTED]:[calculator]:[1304]>
and the code that I am using is right from them!
Help please. I just need to get off the ground with a HELLO WORLD. :-(
What do I need to do to compile the Calculator sample code?
I have also written a web service client to talk to an existing
HelloWorld web service that I wrote. I generated the code from the wsdl
but I cannot successfully compile that either. for those willing to
investigate this with me also, I'd be most appreciative.
--
------
Gavin M. Bell
Computer Science Research Scientist
Computing Applications and Research Dept.
Lawrence Livermore National Labs
L-103
[EMAIL PROTECTED]
-------
"I'm trying real hard to be the shepherd."
-Samuel Jackson (Pulp Fiction)
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains Client Stub implementation for remote web service.
*/
#include "Calculator.hpp"
#include <axis/AxisWrapperAPI.hpp>
#include <string.h>
using namespace std;
Calculator::Calculator(const char* pchEndpointUri, AXIS_PROTOCOL_TYPE eProtocol)
:Stub(pchEndpointUri, eProtocol)
{
}
Calculator::Calculator()
:Stub(" ", APTHTTP1_1)
{
m_pCall->setEndpointURI("http://localhost/axis/Calculator");
}
Calculator::~Calculator()
{
}
/*Methods corresponding to the web service methods*/
/*
* This method wrap the service method add
*/
xsd__int Calculator::add(xsd__int Value0, xsd__int Value1)
{
xsd__int* Ret = NULL;
const char* pcCmplxFaultName;
try
{
if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER))
return *Ret;
if (NULL==m_pCall->getTransportProperty("SOAPAction",false))
{
m_pCall->setTransportProperty(SOAPACTION_HEADER , "Calculator#add");
}
m_pCall->setSOAPVersion(SOAP_VER_1_1);
m_pCall->setOperation("add", "http://localhost/axis/Calculator");
applyUserPreferences();
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("addResponse", "http://localhost/axis/Calculator"))
{
Ret = m_pCall->getElementAsInt("addReturn", 0);
}
}
m_pCall->unInitialize();
xsd__int r = *Ret;
delete Ret;
return r;
}
catch(AxisException& e)
{
int iExceptionCode = e.getExceptionCode();
if(AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)
{
throw SoapFaultException(e);
}
ISoapFault* pSoapFault = (ISoapFault*)
m_pCall->checkFault("Fault","http://localhost/axis/Calculator" );
if(pSoapFault)
{
m_pCall->unInitialize();
throw SoapFaultException(e);
}
else throw;
}
}
/*
* This method wrap the service method sub
*/
xsd__int Calculator::sub(xsd__int Value0, xsd__int Value1)
{
xsd__int* Ret = NULL;
const char* pcCmplxFaultName;
try
{
if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER))
return *Ret;
if (NULL==m_pCall->getTransportProperty("SOAPAction",false))
{
m_pCall->setTransportProperty(SOAPACTION_HEADER , "Calculator#sub");
}
m_pCall->setSOAPVersion(SOAP_VER_1_1);
m_pCall->setOperation("sub", "http://localhost/axis/Calculator");
applyUserPreferences();
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("subResponse", "http://localhost/axis/Calculator"))
{
Ret = m_pCall->getElementAsInt("subReturn", 0);
}
}
m_pCall->unInitialize();
xsd__int r = *Ret;
delete Ret;
return r;
}
catch(AxisException& e)
{
int iExceptionCode = e.getExceptionCode();
if(AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)
{
throw SoapFaultException(e);
}
ISoapFault* pSoapFault = (ISoapFault*)
m_pCall->checkFault("Fault","http://localhost/axis/Calculator" );
if(pSoapFault)
{
m_pCall->unInitialize();
throw SoapFaultException(e);
}
else throw;
}
}
/*
* This method wrap the service method mul
*/
xsd__int Calculator::mul(xsd__int Value0, xsd__int Value1)
{
xsd__int* Ret = NULL;
const char* pcCmplxFaultName;
try
{
if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER))
return *Ret;
if (NULL==m_pCall->getTransportProperty("SOAPAction",false))
{
m_pCall->setTransportProperty(SOAPACTION_HEADER , "Calculator#mul");
}
m_pCall->setSOAPVersion(SOAP_VER_1_1);
m_pCall->setOperation("mul", "http://localhost/axis/Calculator");
applyUserPreferences();
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("mulResponse", "http://localhost/axis/Calculator"))
{
Ret = m_pCall->getElementAsInt("addReturn", 0);
}
}
m_pCall->unInitialize();
xsd__int r = *Ret;
delete Ret;
return r;
}
catch(AxisException& e)
{
int iExceptionCode = e.getExceptionCode();
if(AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)
{
throw SoapFaultException(e);
}
ISoapFault* pSoapFault = (ISoapFault*)
m_pCall->checkFault("Fault","http://localhost/axis/Calculator" );
if(pSoapFault)
{
m_pCall->unInitialize();
throw SoapFaultException(e);
}
else throw;
}
}
/*
* This method wrap the service method div
*/
xsd__int Calculator::div(xsd__int Value0, xsd__int Value1)
{
xsd__int* Ret = NULL;
const char* pcCmplxFaultName;
try
{
if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER))
return *Ret;
if (NULL==m_pCall->getTransportProperty("SOAPAction",false))
{
m_pCall->setTransportProperty(SOAPACTION_HEADER , "Calculator#div");
}
m_pCall->setSOAPVersion(SOAP_VER_1_1);
m_pCall->setOperation("div", "http://localhost/axis/Calculator");
applyUserPreferences();
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/Calculator"))
{
Ret = m_pCall->getElementAsInt("addReturn", 0);
}
}
m_pCall->unInitialize();
xsd__int r = *Ret;
delete Ret;
return r;
}
catch(AxisException& e)
{
int iExceptionCode = e.getExceptionCode();
if(AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)
{
throw SoapFaultException(e);
}
ISoapFault* pSoapFault = (ISoapFault*)
m_pCall->checkFault("Fault","http://localhost/axis/Calculator" );
if(pSoapFault)
{
m_pCall->unInitialize();
throw SoapFaultException(e);
}
else throw;
}
}
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains Client Stub Class for remote web service
*/
#if !defined(__CALCULATOR_CLIENTSTUB_H__INCLUDED_)
#define __CALCULATOR_CLIENTSTUB_H__INCLUDED_
#include <axis/client/Stub.hpp>
#include <axis/SoapFaultException.hpp>
#include <axis/ISoapFault.hpp>
AXIS_CPP_NAMESPACE_USE
class Calculator :public Stub
{
public:
STORAGE_CLASS_INFO Calculator(const char* pchEndpointUri, AXIS_PROTOCOL_TYPE eProtocol=APTHTTP1_1);
STORAGE_CLASS_INFO Calculator();
public:
STORAGE_CLASS_INFO virtual ~Calculator();
public:
STORAGE_CLASS_INFO xsd__int add(xsd__int Value0, xsd__int Value1);
STORAGE_CLASS_INFO xsd__int sub(xsd__int Value0, xsd__int Value1);
STORAGE_CLASS_INFO xsd__int mul(xsd__int Value0, xsd__int Value1);
STORAGE_CLASS_INFO xsd__int div(xsd__int Value0, xsd__int Value1);
};
#endif /* !defined(__CALCULATOR_CLIENTSTUB_H__INCLUDED_)*/
// Copyright 2003-2004 The Apache Software Foundation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "Calculator.hpp"
#include <axis/AxisException.hpp>
#include <iostream>
bool IsNumber (const char *p);
static void
usage (char *programName, char *defaultURL)
{
cout << "\nUsage:\n"
<< programName << " [-? | div number1 number2 [service_url]] " << endl
<< " -? Show this help.\n"
<< " service_url URL of the service.\n"
<< " Default service URL is assumed to be " << defaultURL << endl;
}
int
main (int argc, char *argv[])
{
char endpoint[256];
char original[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;
// Set default service URL
sprintf (endpoint, "http://localhost/axis/calculator");
sprintf (original, endpoint);
try
{
if (argc == 1)
{
usage (argv[0], endpoint);
return 2;
}
if (argc > 1)
{
if (!strncmp (argv[1], "-", 1))
{
// Check for - only so that it works for
//-?, -h or --help; -anything
usage (argv[0], endpoint);
return 2;
}
//less than minimum number of args OR greater than maximum number of args
else if (argc < 4 || argc > 5)
{
usage (argv[0], endpoint);
return 2;
}
else if (argc == 5)
{
sprintf (endpoint, argv[4]);
}
}
cout << endl << " Using service at " << endpoint << endl << endl;
Calculator ws (endpoint);
op = argv[1];
p1 = argv[2];
p2 = argv[3];
if (!IsNumber (p1))
{
printf ("Invalid value for first <parameter> %s\n\n", p1);
usage (argv[0], original);
return 2;
}
if (!IsNumber (p2))
{
printf ("Invalid value for second <parameter> %s\n\n", p2);
usage (argv[0], original);
return 2;
}
i1 = atoi (p1);
i2 = atoi (p2);
if (strcmp (op, "add") == 0)
{
iResult = ws.add (i1, i2);
printf ("%d\n", iResult);
}
else if (strcmp (op, "sub") == 0)
{
iResult = ws.sub (i1, i2);
printf ("%d\n", iResult);
}
else if (strcmp (op, "mul") == 0)
{
iResult = ws.mul (i1, i2);
printf ("%d\n", iResult);
}
else if (strcmp (op, "div") == 0)
{
iResult = ws.div (i1, i2);
printf ("%d\n", iResult);
}
else
{
printf ("Invalid operation %s\n\n", op);
usage (argv[0], original);
return 2;
}
}
catch (AxisException & e)
{
printf ("Exception : %s\n", e.what ());
}
catch (exception & e)
{
printf ("Unknown exception has occured\n");
}
catch (...)
{
printf ("Unknown exception has occured\n");
}
return 0;
}
bool
IsNumber (const char *p)
{
for (int x = 0; x < strlen (p); x++)
{
if (!isdigit (p[x]))
return false;
}
return true;
}
// Copyright 2003-2004 The Apache Software Foundation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "HelloModel.hpp"
#include <axis/AxisException.hpp>
#include <iostream>
static void
usage (char *programName, char *defaultURL)
{
cout << "\nUsage:\n"
<< programName << " [echoString] " << endl
<< " service_url URL of the service.\n"
<< " Default service URL is assumed to be " << defaultURL << endl;
}
int
main (int argc, char *argv[])
{
char endpoint[256];
char original[256];
const char *server = "localhost";
const char *port = "1595";
const char *inputString = "<test-echo-string>";
const char *resultString = "<no-result>";
// Set default service URL
sprintf (endpoint, "http://localhost:1595/NaracWS/services/HelloModel");
sprintf (original, endpoint);
try
{
if (argc < 1)
{
usage (argv[0], endpoint);
return 2;
}
cout << endl << " Using service at " << endpoint << endl << endl;
HelloModel ws (endpoint);
inputString = argv[1];
resultString = ws.request(inputString);
printf ("%s\n", resultString);
}
catch (AxisException & e)
{
printf ("Exception : %s\n", e.what ());
}
catch (exception & e)
{
printf ("Unknown exception has occured\n");
}
catch (...)
{
printf ("Unknown exception has occured\n");
}
return 0;
}
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains Client Stub implementation for remote web service.
*/
#include "HelloModel.hpp"
#include <axis/AxisWrapperAPI.hpp>
#include <string.h>
using namespace std;
HelloModel::HelloModel(const char* pchEndpointUri, AXIS_PROTOCOL_TYPE eProtocol)
:Stub(pchEndpointUri, eProtocol)
{
}
HelloModel::HelloModel()
:Stub(" ", APTHTTP1_1)
{
m_pCall->setEndpointURI("http://localhost:1595/NaracWS/services/HelloModel");
}
HelloModel::~HelloModel()
{
}
/*Methods corresponding to the web service methods*/
/*
* This method wrap the service method request
*/
xsd__string HelloModel::request(xsd__string Value0)
{
xsd__string Ret;
memset(&Ret,0,sizeof(xsd__string));
const char* pcCmplxFaultName;
try
{
if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER))
return Ret;
if (NULL==m_pCall->getTransportProperty("SOAPAction",false))
{
m_pCall->setTransportProperty(SOAPACTION_HEADER , "");
}
m_pCall->setSOAPVersion(SOAP_VER_1_1);
m_pCall->setOperation("request", "http://localhost:1595/NaracWS/services/HelloModel");
applyUserPreferences();
m_pCall->addParameter((void*)Value0, "msg", XSD_STRING);
if (AXIS_SUCCESS == m_pCall->invoke())
{
if(AXIS_SUCCESS == m_pCall->checkMessage("requestResponse", "http://localhost:1595/NaracWS/services/HelloModel"))
{
Ret = m_pCall->getElementAsString("requestReturn", 0);
}
}
m_pCall->unInitialize();
return Ret;
}
catch(AxisException& e)
{
int iExceptionCode = e.getExceptionCode();
if(AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)
{
throw SoapFaultException(e);
}
ISoapFault* pSoapFault = (ISoapFault*)
m_pCall->checkFault("Fault","http://localhost:1595/NaracWS/services/HelloModel" );
if(pSoapFault)
{
m_pCall->unInitialize();
throw SoapFaultException(e);
}
else throw;
}
}
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains Client Stub Class for remote web service
*/
#if !defined(__HELLOMODEL_CLIENTSTUB_H__INCLUDED_)
#define __HELLOMODEL_CLIENTSTUB_H__INCLUDED_
#include <axis/client/Stub.hpp>
#include <axis/SoapFaultException.hpp>
#include <axis/ISoapFault.hpp>
AXIS_CPP_NAMESPACE_USE
class HelloModel :public Stub
{
public:
STORAGE_CLASS_INFO HelloModel(const char* pchEndpointUri, AXIS_PROTOCOL_TYPE eProtocol=APTHTTP1_1);
STORAGE_CLASS_INFO HelloModel();
public:
STORAGE_CLASS_INFO virtual ~HelloModel();
public:
STORAGE_CLASS_INFO xsd__string request(xsd__string Value0);
};
#endif /* !defined(__HELLOMODEL_CLIENTSTUB_H__INCLUDED_)*/
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://localhost:1595/NaracWS/services/HelloModel" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://localhost:1595/NaracWS/services/HelloModel" xmlns:intf="http://localhost:1595/NaracWS/services/HelloModel" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.2.1
Built on Jun 14, 2005 (09:15:57 EDT)-->
<wsdl:message name="requestResponse">
<wsdl:part name="requestReturn" type="soapenc:string"/>
</wsdl:message>
<wsdl:message name="requestRequest">
<wsdl:part name="msg" type="soapenc:string"/>
</wsdl:message>
<wsdl:portType name="HelloModel">
<wsdl:operation name="request" parameterOrder="msg">
<wsdl:input message="impl:requestRequest" name="requestRequest"/>
<wsdl:output message="impl:requestResponse" name="requestResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloModelSoapBinding" type="impl:HelloModel">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="request">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="requestRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://hellomodel.services.narac.llnl.gov" use="encoded"/>
</wsdl:input>
<wsdl:output name="requestResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:1595/NaracWS/services/HelloModel" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloModelService">
<wsdl:port binding="impl:HelloModelSoapBinding" name="HelloModel">
<wsdlsoap:address location="http://localhost:1595/NaracWS/services/HelloModel"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>