summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/components/webservice
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/components/webservice')
-rw-r--r--sca-cpp/trunk/components/webservice/Makefile.am5
-rw-r--r--sca-cpp/trunk/components/webservice/axiom-test.cpp12
-rw-r--r--sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp2
-rw-r--r--sca-cpp/trunk/components/webservice/axis2-service.cpp20
-rw-r--r--sca-cpp/trunk/components/webservice/axis2-test.cpp15
-rw-r--r--sca-cpp/trunk/components/webservice/axis2.hpp41
-rw-r--r--sca-cpp/trunk/components/webservice/client-test.cpp30
-rwxr-xr-xsca-cpp/trunk/components/webservice/echo-test1
-rwxr-xr-xsca-cpp/trunk/components/webservice/server-test1
-rw-r--r--sca-cpp/trunk/components/webservice/webservice-client.cpp4
-rw-r--r--sca-cpp/trunk/components/webservice/webservice-listener.cpp10
11 files changed, 69 insertions, 72 deletions
diff --git a/sca-cpp/trunk/components/webservice/Makefile.am b/sca-cpp/trunk/components/webservice/Makefile.am
index 242b97dce8..3b5a53695e 100644
--- a/sca-cpp/trunk/components/webservice/Makefile.am
+++ b/sca-cpp/trunk/components/webservice/Makefile.am
@@ -62,10 +62,11 @@ axis2_test_SOURCES = axis2-test.cpp
axis2_test_LDFLAGS = -lxml2 -L${AXIS2C_LIB} -R${AXIS2C_LIB} -laxis2_engine -laxis2_axiom -laxutil
client_test_SOURCES = client-test.cpp
-client_test_LDFLAGS = -lxml2 -lcurl -lmozjs -L${AXIS2C_LIB} -R${AXIS2C_LIB} -laxis2_engine -laxis2_axiom -laxutil
+client_test_LDFLAGS = -lxml2 -lcurl -ljansson -L${AXIS2C_LIB} -R${AXIS2C_LIB} -laxis2_engine -laxis2_axiom -laxutil
dist_noinst_SCRIPTS = echo-test server-test
noinst_PROGRAMS = axiom-test axis2-test client-test
-TESTS = axiom-test echo-test server-test
+#TESTS = axiom-test echo-test server-test
+TESTS = axiom-test
endif
diff --git a/sca-cpp/trunk/components/webservice/axiom-test.cpp b/sca-cpp/trunk/components/webservice/axiom-test.cpp
index 75ce2452fd..eaa9921d1b 100644
--- a/sca-cpp/trunk/components/webservice/axiom-test.cpp
+++ b/sca-cpp/trunk/components/webservice/axiom-test.cpp
@@ -45,11 +45,11 @@ const string customerElement =
"<account><id>4567</id><balance>3000</balance></account>"
"</customer>";
-const string echo("<ns1:echoString xmlns:ns1=\"http://ws.apache.org/axis2/services/echo\">\n"
- " <text>Hello World!</text>\n"
+const string echo("<ns1:echoString xmlns:ns1=\"http://ws.apache.org/axis2/services/echo\">"
+ "<text>Hello World!</text>"
"</ns1:echoString>");
-bool testAxiom() {
+const bool testAxiom() {
const Axis2Context ax;
{
const failable<axiom_node_t*> n = stringToAxiomNode(customerElement, ax);
@@ -60,9 +60,9 @@ bool testAxiom() {
}
{
const list<value> arg = mklist<value>(
- list<value>() + "ns1:echoString"
- + (list<value>() + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo"))
- + (list<value>() + "text" + string("Hello World!")));
+ nilListValue + "ns1:echoString"
+ + (nilListValue + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo"))
+ + (nilListValue + "text" + string("Hello World!")));
const failable<axiom_node_t*> n = valuesToAxiomNode(arg, ax);
assert(hasContent(n));
const failable<const string> x = axiomNodeToString(content(n), ax);
diff --git a/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp b/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp
index dafa6fd229..7a0869d20f 100644
--- a/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp
+++ b/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp
@@ -105,7 +105,7 @@ const axis2_module_ops_t dispatchOps = {
dispatchFuncMap
};
-axis2_module_t * dispatchModule(const axutil_env_t* env) {
+axis2_module_t* dispatchModule(const axutil_env_t* env) {
axis2_module_t *module = (axis2_module_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_module_t));
if (module == NULL)
return NULL;
diff --git a/sca-cpp/trunk/components/webservice/axis2-service.cpp b/sca-cpp/trunk/components/webservice/axis2-service.cpp
index 4df0543370..41cce080b5 100644
--- a/sca-cpp/trunk/components/webservice/axis2-service.cpp
+++ b/sca-cpp/trunk/components/webservice/axis2-service.cpp
@@ -50,7 +50,7 @@ int AXIS2_CALL serviceFree(axis2_svc_skeleton_t* svc_skeleton, const axutil_env_
typedef struct axis2_apache2_out_transport_info {
axis2_http_out_transport_info_t out_transport_info;
- request_rec *request;
+ request_rec* request;
axis2_char_t *encoding;
} axis2_apache2_out_transport_info_t;
@@ -66,25 +66,25 @@ axiom_node_t *AXIS2_CALL serviceInvoke(unused axis2_svc_skeleton_t* svc_skeleton
// Check that we have an input node
if (node == NULL || axiom_node_get_node_type(node, env) != AXIOM_ELEMENT)
return NULL;
- axiom_element_t *e = (axiom_element_t *) axiom_node_get_data_element(node, env);
+ axiom_element_t* const e = (axiom_element_t*) axiom_node_get_data_element(node, env);
if (e == NULL)
return NULL;
// Get the function name
- const char* func = axiom_element_get_localname(e, env);
+ const char* const func = axiom_element_get_localname(e, env);
if (func == NULL)
return NULL;
// Get the target endpoint address
- const axis2_endpoint_ref_t* epr = axis2_msg_ctx_get_from(msg_ctx, env);
+ const axis2_endpoint_ref_t* const epr = axis2_msg_ctx_get_from(msg_ctx, env);
if (epr == NULL)
return NULL;
- string address = axis2_endpoint_ref_get_address(epr, env);
+ unused const string address = axis2_endpoint_ref_get_address(epr, env);
// Get the underlying HTTPD request
- axis2_out_transport_info_t* tinfo = axis2_msg_ctx_get_out_transport_info(msg_ctx, env);
- axis2_apache2_out_transport_info_t* httpinfo = (axis2_apache2_out_transport_info_t*)tinfo;
- request_rec* r = httpinfo->request;
+ axis2_out_transport_info_t* const tinfo = axis2_msg_ctx_get_out_transport_info(msg_ctx, env);
+ axis2_apache2_out_transport_info_t* const httpinfo = (axis2_apache2_out_transport_info_t*)tinfo;
+ request_rec* const r = httpinfo->request;
debug_httpdRequest(r, "webservice::serviceInvoke");
// Parse the request Axiom node and construct request expression
@@ -96,9 +96,9 @@ axiom_node_t *AXIS2_CALL serviceInvoke(unused axis2_svc_skeleton_t* svc_skeleton
debug(expr, "webservice::serviceInvoke::expr");
// Retrieve the target lambda function from the HTTPD request and invoke it
- const value* rv = const_cast<const value*>((value*)ap_get_module_config(r->request_config, &axis2_module));
+ const value* const rv = const_cast<const value*>((value*)ap_get_module_config(r->request_config, &axis2_module));
cout << "relay: " << rv << endl;
- const lambda<value(const list<value>&)> relay = *rv;
+ const lvvlambda relay = *rv;
const value res = relay(expr);
debug(res, "webservice::serviceInvoke::result");
diff --git a/sca-cpp/trunk/components/webservice/axis2-test.cpp b/sca-cpp/trunk/components/webservice/axis2-test.cpp
index d7c2f3b671..69723aa6b3 100644
--- a/sca-cpp/trunk/components/webservice/axis2-test.cpp
+++ b/sca-cpp/trunk/components/webservice/axis2-test.cpp
@@ -36,22 +36,23 @@
namespace tuscany {
namespace webservice {
-bool testEval() {
+const bool testEval() {
const Axis2Context ax;
const value func = "http://ws.apache.org/axis2/c/samples/echoString";
const list<value> arg = mklist<value>(
- list<value>() + "ns1:echoString"
- + (list<value>() + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo"))
- + (list<value>() + "text" + string("Hello World!")));
+ nilListValue + "ns1:echoString"
+ + (nilListValue + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo"))
+ + (nilListValue + "text" + string("Hello World!")));
const failable<value> rval = evalExpr(mklist<value>(func, arg, string("http://localhost:9090/axis2/services/echo")), ax);
assert(hasContent(rval));
const list<value> r = mklist<value>(
- list<value>() + "ns1:echoString"
- + (list<value>() + "@xmlns:ns1" + string("http://ws.apache.org/axis2/c/samples"))
- + (list<value>() + "text" + string("Hello World!")));
+ nilListValue + "ns1:echoString"
+ + (nilListValue + "@xmlns:ns1" + string("http://ws.apache.org/axis2/c/samples"))
+ + (nilListValue + "text" + string("Hello World!")));
+ cerr << content(rval) << endl;
assert(content(rval) == r);
return true;
diff --git a/sca-cpp/trunk/components/webservice/axis2.hpp b/sca-cpp/trunk/components/webservice/axis2.hpp
index 9bad109ff0..fd4d1f9a02 100644
--- a/sca-cpp/trunk/components/webservice/axis2.hpp
+++ b/sca-cpp/trunk/components/webservice/axis2.hpp
@@ -46,8 +46,8 @@
#include "sstream.hpp"
#include "list.hpp"
#include "value.hpp"
-#include "xml.hpp"
#include "monad.hpp"
+#include "../../modules/xml/xml.hpp"
namespace tuscany {
namespace webservice {
@@ -65,16 +65,9 @@ public:
debug("webservice::axis2context::copy");
}
- const Axis2Context& operator=(const Axis2Context& ax) {
- debug("webservice::axis2context::operator=");
- if(this == &ax)
- return *this;
- env = ax.env;
- owner = false;
- return *this;
- }
+ Axis2Context& operator=(const Axis2Context& ax) = delete;
- Axis2Context(const axutil_env_t* env) : env(const_cast<axutil_env_t*>(env)), owner(false) {
+ Axis2Context(const axutil_env_t* const env) : env(const_cast<axutil_env_t*>(env)), owner(false) {
debug("webservice::axis2context::env");
}
@@ -86,13 +79,13 @@ public:
}
private:
- axutil_env_t* env;
- bool owner;
+ axutil_env_t* const env;
+ const bool owner;
- friend const axutil_env_t* env(const Axis2Context& ax);
+ friend const axutil_env_t* const env(const Axis2Context& ax);
};
-const axutil_env_t* env(const Axis2Context& ax) {
+const axutil_env_t* const env(const Axis2Context& ax) {
return ax.env;
}
@@ -109,7 +102,7 @@ const string axis2Error(const Axis2Context& ax) {
* Convert a string to an Axiom node.
*/
const failable<axiom_node_t*> stringToAxiomNode(const string& s, const Axis2Context& ax) {
- axiom_node_t* node = axiom_node_create_from_buffer(env(ax), const_cast<axis2_char_t*>(c_str(s)));
+ axiom_node_t* const node = axiom_node_create_from_buffer(env(ax), const_cast<axis2_char_t*>(c_str(s)));
if (node == NULL)
return mkfailure<axiom_node_t*>(string("Couldn't convert XML to Axiom node: ") + axis2Error(ax));
return node;
@@ -119,7 +112,7 @@ const failable<axiom_node_t*> stringToAxiomNode(const string& s, const Axis2Cont
* Convert a list of values representing XML elements to an Axiom node.
*/
const failable<axiom_node_t*> valuesToAxiomNode(const list<value>& l, const Axis2Context& ax) {
- const failable<list<string> > xml = writeXML(valuesToElements(l), false);
+ const failable<list<string> > xml = xml::writeElements(valuesToElements(l), false);
if (!hasContent(xml))
return mkfailure<axiom_node_t*>(xml);
ostringstream os;
@@ -130,8 +123,8 @@ const failable<axiom_node_t*> valuesToAxiomNode(const list<value>& l, const Axis
/**
* Convert an axiom node to a string.
*/
-const failable<const string> axiomNodeToString(axiom_node_t* node, const Axis2Context& ax) {
- const char* c = axiom_node_to_string(node, env(ax));
+const failable<const string> axiomNodeToString(axiom_node_t* const node, const Axis2Context& ax) {
+ const char* const c = axiom_node_to_string(node, env(ax));
if (c == NULL)
return mkfailure<const string>(string("Couldn't convert Axiom node to XML: ") + axis2Error(ax));
const string s(c);
@@ -142,12 +135,12 @@ const failable<const string> axiomNodeToString(axiom_node_t* node, const Axis2Co
/**
* Convert an axiom node to a list of values representing XML elements.
*/
-const failable<const list<value> > axiomNodeToValues(axiom_node_t* node, const Axis2Context& ax) {
+const failable<const list<value> > axiomNodeToValues(axiom_node_t* const node, const Axis2Context& ax) {
const failable<const string> s = axiomNodeToString(node, ax);
if (!hasContent(s))
return mkfailure<const list<value> >(s);
istringstream is(content(s));
- const failable<const list<value> > l = readXML(streamList(is));
+ const failable<const list<value> > l = content(xml::readElements(streamList(is)));
if (!hasContent(l))
return l;
return elementsToValues(content(l));
@@ -166,11 +159,11 @@ const failable<value> evalExpr(const value& expr, const Axis2Context& ax) {
const value uri(caddr<value>(expr));
// Create Axis2 client
- axis2_svc_client_t *client = axis2_svc_client_create(env(ax), getenv("AXIS2C_HOME"));
+ axis2_svc_client_t* const client = axis2_svc_client_create(env(ax), getenv("AXIS2C_HOME"));
if (client == NULL)
return mkfailure<value>("Couldn't create Axis2 client: " + axis2Error(ax));
- axis2_endpoint_ref_t *epr = axis2_endpoint_ref_create(env(ax), c_str(uri));
- axis2_options_t *opt = axis2_options_create(env(ax));
+ axis2_endpoint_ref_t* const epr = axis2_endpoint_ref_create(env(ax), c_str(uri));
+ axis2_options_t* const opt = axis2_options_create(env(ax));
axis2_options_set_to(opt, env(ax), epr);
axis2_options_set_action(opt, env(ax), (const axis2_char_t*)c_str(func));
axis2_svc_client_set_options(client, env(ax), opt);
@@ -182,7 +175,7 @@ const failable<value> evalExpr(const value& expr, const Axis2Context& ax) {
return mkfailure<value>(req);
// Call the Web service
- axiom_node_t* res = axis2_svc_client_send_receive(client, env(ax), content(req));
+ axiom_node_t* const res = axis2_svc_client_send_receive(client, env(ax), content(req));
if (res == NULL) {
axis2_svc_client_free(client, env(ax));
return mkfailure<value>("Couldn't invoke Axis2 service: " + axis2Error(ax));
diff --git a/sca-cpp/trunk/components/webservice/client-test.cpp b/sca-cpp/trunk/components/webservice/client-test.cpp
index 16dd659b22..ca009b9594 100644
--- a/sca-cpp/trunk/components/webservice/client-test.cpp
+++ b/sca-cpp/trunk/components/webservice/client-test.cpp
@@ -38,43 +38,43 @@ namespace tuscany {
namespace webservice {
-bool testModAxis2() {
+const bool testModAxis2() {
const Axis2Context ax;
const value func = "http://ws.apache.org/axis2/c/samples/echoString";
const list<value> arg = mklist<value>(
- list<value>() + "ns1:echoString"
- + (list<value>() + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo"))
- + (list<value>() + "text" + string("Hello World!")));
+ nilListValue + "ns1:echoString"
+ + (nilListValue + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo"))
+ + (nilListValue + "text" + string("Hello World!")));
const failable<value> rval = evalExpr(mklist<value>(func, arg, string("http://localhost:8090/echo-listener")), ax);
assert(hasContent(rval));
const list<value> r = mklist<value>(
- list<value>() + "ns1:echoString"
- + (list<value>() + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo"))
- + (list<value>() + "text" + string("Hello World!")));
+ nilListValue + "ns1:echoString"
+ + (nilListValue + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo"))
+ + (nilListValue + "text" + string("Hello World!")));
assert(content(rval) == r);
return true;
}
-bool testEval() {
- http::CURLSession cs("", "", "", "");
+const bool testEval() {
+ const http::CURLSession cs("", "", "", "", 0);
const value func = "http://ws.apache.org/axis2/c/samples/echoString";
const list<value> arg = mklist<value>(
- list<value>() + "ns1:echoString"
- + (list<value>() + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo"))
- + (list<value>() + "text" + string("Hello World!")));
+ nilListValue + "ns1:echoString"
+ + (nilListValue + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo"))
+ + (nilListValue + "text" + string("Hello World!")));
const failable<value> rval = http::evalExpr(mklist<value>(func, arg), "http://localhost:8090/echo-client", cs);
assert(hasContent(rval));
const list<value> r = mklist<value>(
- list<value>() + "ns1:echoString"
- + (list<value>() + "@xmlns:ns1" + string("http://ws.apache.org/axis2/c/samples"))
- + (list<value>() + "text" + string("Hello World!")));
+ nilListValue + "ns1:echoString"
+ + (nilListValue + "@xmlns:ns1" + string("http://ws.apache.org/axis2/c/samples"))
+ + (nilListValue + "text" + string("Hello World!")));
assert(content(rval) == r);
return true;
}
diff --git a/sca-cpp/trunk/components/webservice/echo-test b/sca-cpp/trunk/components/webservice/echo-test
index 1056a6c668..a7bc636cab 100755
--- a/sca-cpp/trunk/components/webservice/echo-test
+++ b/sca-cpp/trunk/components/webservice/echo-test
@@ -20,6 +20,7 @@
# Setup
axis2_prefix=`cat axis2c.prefix`
export AXIS2C_HOME=$axis2_prefix
+export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$axis2_prefix/lib
axis2="$axis2_prefix/bin/axis2_http_server"
pwd=`pwd`
cd "$axis2_prefix/bin"
diff --git a/sca-cpp/trunk/components/webservice/server-test b/sca-cpp/trunk/components/webservice/server-test
index cb12accbfb..5e3b18b376 100755
--- a/sca-cpp/trunk/components/webservice/server-test
+++ b/sca-cpp/trunk/components/webservice/server-test
@@ -33,6 +33,7 @@ EOF
axis2_prefix=`cat axis2c.prefix`
export AXIS2C_HOME=$axis2_prefix
+export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$axis2_prefix/lib
axis2="$axis2_prefix/bin/axis2_http_server"
pwd=`pwd`
cd "$axis2_prefix/bin"
diff --git a/sca-cpp/trunk/components/webservice/webservice-client.cpp b/sca-cpp/trunk/components/webservice/webservice-client.cpp
index 76d4905bf8..bece0b3b3a 100644
--- a/sca-cpp/trunk/components/webservice/webservice-client.cpp
+++ b/sca-cpp/trunk/components/webservice/webservice-client.cpp
@@ -42,10 +42,10 @@ const failable<value> apply(const value& func, const list<value>& params) {
// Extract parameters
const value doc = car<value>(params);
- const lambda<value(const list<value>&)> l = cadr<value>(params);
+ const lvvlambda l = cadr<value>(params);
// Call the URI property lambda function to get the configured URI
- const value uri = l(list<value>());
+ const value uri = l(nilListValue);
// Evaluate using Axis2
return evalExpr(mklist<value>(func, doc, uri), ax);
diff --git a/sca-cpp/trunk/components/webservice/webservice-listener.cpp b/sca-cpp/trunk/components/webservice/webservice-listener.cpp
index 29ebef4bcb..f9c18f293a 100644
--- a/sca-cpp/trunk/components/webservice/webservice-listener.cpp
+++ b/sca-cpp/trunk/components/webservice/webservice-listener.cpp
@@ -44,10 +44,10 @@ extern "C" {
extern module axis2_module;
}
-const value redirectToAxis2(const string& uri, request_rec* r, const value& relay) {
- const failable<request_rec*, int> nr = httpd::internalRedirectRequest(uri, r);
+const failable<value> redirectToAxis2(const string& uri, request_rec* const r, const value& relay) {
+ const failable<request_rec*> nr = httpd::internalRedirectRequest(uri, r);
if (!hasContent(nr))
- return value(reason(nr), rcode(nr));
+ return mkfailure<value>(reason(nr), rcode(nr));
ap_set_module_config(content(nr)->request_config, &axis2_module, const_cast<void*>((const void*)&relay));
return value(httpd::internalRedirect(content(nr)));
}
@@ -58,7 +58,7 @@ const value redirectToAxis2(const string& uri, request_rec* r, const value& rela
const failable<value> handle(const list<value>& params) {
// Extract HTTPD request from the params
- request_rec* r = httpd::request(car(params));
+ request_rec* const r = httpd::request(car(params));
debug_httpdRequest(r, "webservice::handle");
// Extract the relay lambda from the params and store it in the HTTPD request,
@@ -67,7 +67,7 @@ const failable<value> handle(const list<value>& params) {
cout << "relay: " << &relay << endl;
// Redirect HTTPD request to Mod-axis2
- return redirectToAxis2(string("/axis2") + r->uri + r->args != NULL? string("?") + r->args : string(""), r, relay);
+ return redirectToAxis2(string("/axis2") + r->uri + r->args != NULL? string("?") + r->args : emptyString, r, relay);
}
}