Author: damitha Date: Sat Aug 30 01:09:31 2008 New Revision: 690481 URL: http://svn.apache.org/viewvc?rev=690481&view=rev Log: Close sequence is now sent with LastMsgNumber element Added: webservices/sandesha/trunk/c/include/sandesha2_last_msg_number.h webservices/sandesha/trunk/c/src/wsrm/last_msg_number.c Modified: webservices/sandesha/trunk/c/include/sandesha2_client.h webservices/sandesha/trunk/c/include/sandesha2_close_seq.h webservices/sandesha/trunk/c/include/sandesha2_constants.h webservices/sandesha/trunk/c/src/client/client.c webservices/sandesha/trunk/c/src/wsrm/Makefile.am webservices/sandesha/trunk/c/src/wsrm/close_seq.c Modified: webservices/sandesha/trunk/c/include/sandesha2_client.h URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/include/sandesha2_client.h?rev=690481&r1=690480&r2=690481&view=diff ============================================================================== --- webservices/sandesha/trunk/c/include/sandesha2_client.h (original) +++ webservices/sandesha/trunk/c/include/sandesha2_client.h Sat Aug 30 01:09:31 2008 @@ -129,13 +129,15 @@ sandesha2_client_close_seq_with_svc_client( const axutil_env_t *env, axis2_svc_client_t *svc_client, - axis2_callback_t *callback); + axis2_callback_t *callback, + long last_msg_num); AXIS2_EXTERN axis2_status_t AXIS2_CALL sandesha2_client_close_seq_with_svc_client_and_seq_key( const axutil_env_t *env, axis2_svc_client_t *svc_client, - axis2_char_t *seq_key); + axis2_char_t *seq_key, + long last_msg_num); /** * This blocks the system until the messages sent have been completed. Modified: webservices/sandesha/trunk/c/include/sandesha2_close_seq.h URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/include/sandesha2_close_seq.h?rev=690481&r1=690480&r2=690481&view=diff ============================================================================== --- webservices/sandesha/trunk/c/include/sandesha2_close_seq.h (original) +++ webservices/sandesha/trunk/c/include/sandesha2_close_seq.h Sat Aug 30 01:09:31 2008 @@ -27,6 +27,7 @@ #include #include #include +#include #ifdef __cplusplus @@ -95,6 +96,17 @@ const axutil_env_t *env, void *om_node); +axis2_status_t AXIS2_CALL +sandesha2_close_seq_set_last_msg_number( + sandesha2_close_seq_t *close_seq, + const axutil_env_t *env, + sandesha2_last_msg_number_t *last_msg_number); + +sandesha2_last_msg_number_t * AXIS2_CALL +sandesha2_close_seq_get_last_msg_number( + sandesha2_close_seq_t *close_seq, + const axutil_env_t *env); + /** @} */ #ifdef __cplusplus } Modified: webservices/sandesha/trunk/c/include/sandesha2_constants.h URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/include/sandesha2_constants.h?rev=690481&r1=690480&r2=690481&view=diff ============================================================================== --- webservices/sandesha/trunk/c/include/sandesha2_constants.h (original) +++ webservices/sandesha/trunk/c/include/sandesha2_constants.h Sat Aug 30 01:09:31 2008 @@ -107,6 +107,8 @@ #define SANDESHA2_WSMC_COMMON_NS_PREFIX_RM "wsmc" #define SANDESHA2_WSRM_COMMON_MSG_NUMBER "MessageNumber" + + #define SANDESHA2_WSRM_COMMON_LAST_MSG_NUMBER "LastMsgNumber" #define SANDESHA2_WSRM_COMMON_LAST_MSG "LastMessage" Added: webservices/sandesha/trunk/c/include/sandesha2_last_msg_number.h URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/include/sandesha2_last_msg_number.h?rev=690481&view=auto ============================================================================== --- webservices/sandesha/trunk/c/include/sandesha2_last_msg_number.h (added) +++ webservices/sandesha/trunk/c/include/sandesha2_last_msg_number.h Sat Aug 30 01:09:31 2008 @@ -0,0 +1,101 @@ +/* + * Copyright 2004,2005 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. + */ + +#ifndef SANDESHA2_LAST_MSG_NUMBER_H +#define SANDESHA2_LAST_MSG_NUMBER_H + +/** + * @file sandesha2_last_msg_number.h + * @brief + */ + +#include +#include +#include + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** @defgroup sandesha2_last_msg_number + * @ingroup sandesha2_wsrm + * @{ + */ +typedef struct sandesha2_last_msg_number_t sandesha2_last_msg_number_t; + +/** + * @brief Last Msg Number ops struct + * Encapsulator struct for ops of sandesha2_last_msg_number + */ + +/** + * @brief sandesha2_last_msg_number + * sandesha2_last_msg_number + */ + +AXIS2_EXTERN sandesha2_last_msg_number_t* AXIS2_CALL +sandesha2_last_msg_number_create( + const axutil_env_t *env, + axis2_char_t *ns_value); + +axis2_status_t AXIS2_CALL +sandesha2_last_msg_number_free_void_arg( + void *msg_num, + const axutil_env_t *env); + +axis2_status_t AXIS2_CALL +sandesha2_last_msg_number_free( + sandesha2_last_msg_number_t *msg_num, + const axutil_env_t *env); + +axis2_char_t* AXIS2_CALL +sandesha2_last_msg_number_get_namespace_value( + sandesha2_last_msg_number_t *msg_num, + const axutil_env_t *env); + +axis2_status_t AXIS2_CALL +sandesha2_last_msg_number_set_last_msg_number( + sandesha2_last_msg_number_t *msg_num, + const axutil_env_t *env, + long value); + +long AXIS2_CALL +sandesha2_last_msg_number_get_last_msg_number( + sandesha2_last_msg_number_t *msg_num, + const axutil_env_t *env); + +void* AXIS2_CALL +sandesha2_last_msg_number_from_om_node( + sandesha2_last_msg_number_t *msg_num, + const axutil_env_t *env, + axiom_node_t *om_node); + +axiom_node_t* AXIS2_CALL +sandesha2_last_msg_number_to_om_node( + sandesha2_last_msg_number_t *msg_num, + const axutil_env_t *env, + void *om_node); + + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* SANDESHA2_LAST_MSG_NUMBER_H */ + Modified: webservices/sandesha/trunk/c/src/client/client.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/client/client.c?rev=690481&r1=690480&r2=690481&view=diff ============================================================================== --- webservices/sandesha/trunk/c/src/client/client.c (original) +++ webservices/sandesha/trunk/c/src/client/client.c Sat Aug 30 01:09:31 2008 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -81,7 +82,8 @@ sandesha2_client_configure_close_seq( const axutil_env_t *env, axis2_options_t *options, - axis2_conf_ctx_t *conf_ctx); + axis2_conf_ctx_t *conf_ctx, + long last_msg_num); static axis2_bool_t sandesha2_client_is_seq_terminated( @@ -798,7 +800,8 @@ sandesha2_client_close_seq_with_svc_client( const axutil_env_t *env, axis2_svc_client_t *svc_client, - axis2_callback_t *callback) + axis2_callback_t *callback, + long last_msg_num) { axis2_svc_ctx_t *svc_ctx = NULL; axis2_options_t *options = NULL; @@ -848,7 +851,7 @@ rm_namespc_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, rm_spec_version); conf_ctx = axis2_svc_ctx_get_conf_ctx(svc_ctx, env); - close_envelope = sandesha2_client_configure_close_seq(env, options, conf_ctx); + close_envelope = sandesha2_client_configure_close_seq(env, options, conf_ctx, last_msg_num); body = axiom_soap_envelope_get_body(close_envelope, env); node = axiom_soap_body_get_base_node(body, env); element = axiom_node_get_data_element(node, env); @@ -888,7 +891,8 @@ sandesha2_client_close_seq_with_svc_client_and_seq_key( const axutil_env_t *env, axis2_svc_client_t *svc_client, - axis2_char_t *seq_key) + axis2_char_t *seq_key, + long last_msg_num) { axis2_options_t *options = NULL; axutil_property_t *property = NULL; @@ -911,7 +915,7 @@ property = axutil_property_create_with_args(env, 0, 0, 0, seq_key); axis2_options_set_property(options, env, SANDESHA2_CLIENT_SEQ_KEY, property); - sandesha2_client_close_seq_with_svc_client(env, svc_client, NULL); + sandesha2_client_close_seq_with_svc_client(env, svc_client, NULL, last_msg_num); axis2_options_set_property(options, env, SANDESHA2_CLIENT_SEQ_KEY, old_property); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, @@ -1296,7 +1300,8 @@ sandesha2_client_configure_close_seq( const axutil_env_t *env, axis2_options_t *options, - axis2_conf_ctx_t *conf_ctx) + axis2_conf_ctx_t *conf_ctx, + long last_msg_num) { axis2_endpoint_ref_t *to_epr = NULL; axis2_char_t *to = NULL; @@ -1313,6 +1318,7 @@ axis2_char_t *rm_spec_version = NULL; axiom_soap_envelope_t *dummy_envelope = NULL; sandesha2_identifier_t *identifier = NULL; + sandesha2_last_msg_number_t *last_msg_number = NULL; sandesha2_seq_report_t *seq_report = NULL; axis2_conf_t *conf = NULL; axutil_property_t *property = NULL; @@ -1441,6 +1447,9 @@ identifier = sandesha2_identifier_create(env, rm_ns_value); sandesha2_identifier_set_identifier(identifier, env, seq_id); sandesha2_close_seq_set_identifier(close_seq, env, identifier); + last_msg_number = sandesha2_last_msg_number_create(env, rm_ns_value); + sandesha2_last_msg_number_set_last_msg_number(last_msg_number, env, last_msg_num); + sandesha2_close_seq_set_last_msg_number(close_seq, env, last_msg_number); sandesha2_close_seq_to_soap_envelope(close_seq, env, dummy_envelope); if(seq_prop_mgr) Modified: webservices/sandesha/trunk/c/src/wsrm/Makefile.am URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/Makefile.am?rev=690481&r1=690480&r2=690481&view=diff ============================================================================== --- webservices/sandesha/trunk/c/src/wsrm/Makefile.am (original) +++ webservices/sandesha/trunk/c/src/wsrm/Makefile.am Sat Aug 30 01:09:31 2008 @@ -14,6 +14,7 @@ expires.c\ fault_code.c\ msg_number.c\ + last_msg_number.c\ last_msg.c\ ack_requested.c\ close_seq.c\ Modified: webservices/sandesha/trunk/c/src/wsrm/close_seq.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/close_seq.c?rev=690481&r1=690480&r2=690481&view=diff ============================================================================== --- webservices/sandesha/trunk/c/src/wsrm/close_seq.c (original) +++ webservices/sandesha/trunk/c/src/wsrm/close_seq.c Sat Aug 30 01:09:31 2008 @@ -25,6 +25,7 @@ struct sandesha2_close_seq_t { sandesha2_identifier_t *identifier; + sandesha2_last_msg_number_t *last_msg_number; axis2_char_t *ns_val; }; @@ -56,6 +57,7 @@ close_seq->ns_val = NULL; close_seq->identifier = NULL; + close_seq->last_msg_number = NULL; close_seq->ns_val = (axis2_char_t *)axutil_strdup(env, ns_val); @@ -85,6 +87,8 @@ } close_seq->identifier = NULL; + close_seq->last_msg_number = NULL; + AXIS2_FREE(env->allocator, close_seq); return AXIS2_SUCCESS; } @@ -125,6 +129,17 @@ return NULL; } + close_seq->last_msg_number = sandesha2_last_msg_number_create(env, close_seq->ns_val); + if(!close_seq->last_msg_number) + { + return NULL; + } + + if(!sandesha2_last_msg_number_from_om_node(close_seq->last_msg_number, env, close_seq_node)) + { + return NULL; + } + return close_seq; } @@ -140,7 +155,8 @@ axiom_node_t *cs_node = NULL; AXIS2_PARAM_CHECK(env->error, om_node, NULL); - + + /* identifier is a MUST element within close sequence. So we need to check it's presense */ if(!close_seq->identifier) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_TO_OM_NULL_ELEMENT, AXIS2_FAILURE); @@ -160,6 +176,12 @@ } sandesha2_identifier_to_om_node(close_seq->identifier, env, cs_node); + + if(close_seq->last_msg_number) + { + sandesha2_last_msg_number_to_om_node(close_seq->last_msg_number, env, cs_node); + } + axiom_node_add_child((axiom_node_t*)om_node, env, cs_node); return (axiom_node_t*)om_node; @@ -190,6 +212,33 @@ return AXIS2_SUCCESS; } +sandesha2_last_msg_number_t * AXIS2_CALL +sandesha2_close_seq_get_last_msg_number( + sandesha2_close_seq_t *close_seq, + const axutil_env_t *env) +{ + return close_seq->last_msg_number; +} + +axis2_status_t AXIS2_CALL +sandesha2_close_seq_set_last_msg_number( + sandesha2_close_seq_t *close_seq, + const axutil_env_t *env, + sandesha2_last_msg_number_t *last_msg_number) +{ + if(close_seq->last_msg_number) + { + + sandesha2_last_msg_number_free(close_seq->last_msg_number, env); + close_seq->last_msg_number = NULL; + + } + + close_seq->last_msg_number = last_msg_number; + + return AXIS2_SUCCESS; +} + axis2_status_t AXIS2_CALL sandesha2_close_seq_to_soap_envelope( sandesha2_close_seq_t *close_seq, Added: webservices/sandesha/trunk/c/src/wsrm/last_msg_number.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/last_msg_number.c?rev=690481&view=auto ============================================================================== --- webservices/sandesha/trunk/c/src/wsrm/last_msg_number.c (added) +++ webservices/sandesha/trunk/c/src/wsrm/last_msg_number.c Sat Aug 30 01:09:31 2008 @@ -0,0 +1,240 @@ +/* + * Copyright 2004,2005 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 +#include +#include +#include +#include +#include + +/** + * @brief LastMsgNumber struct impl + * Sandesha2 LastMsgNumber + */ +struct sandesha2_last_msg_number_t +{ + long msg_num; + axis2_char_t *ns_val; +}; + +static axis2_bool_t AXIS2_CALL +sandesha2_last_msg_number_is_namespace_supported( + const axutil_env_t *env, + axis2_char_t *namespace); + +AXIS2_EXTERN sandesha2_last_msg_number_t* AXIS2_CALL +sandesha2_last_msg_number_create( + const axutil_env_t *env, + axis2_char_t *ns_val) +{ + sandesha2_last_msg_number_t *last_msg_number = NULL; + AXIS2_PARAM_CHECK(env->error, ns_val, NULL); + + if(!sandesha2_last_msg_number_is_namespace_supported(env, ns_val)) + { + AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_UNSUPPORTED_NS, AXIS2_FAILURE); + return NULL; + } + + last_msg_number = (sandesha2_last_msg_number_t *)AXIS2_MALLOC + (env->allocator, sizeof(sandesha2_last_msg_number_t)); + + if(!last_msg_number) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + last_msg_number->ns_val = NULL; + last_msg_number->msg_num = 0; + + last_msg_number->ns_val = (axis2_char_t *)axutil_strdup(env, ns_val); + + return last_msg_number; +} + +axis2_status_t AXIS2_CALL +sandesha2_last_msg_number_free_void_arg( + void *msg_num, + const axutil_env_t *env) +{ + sandesha2_last_msg_number_t *msg_num_l = NULL; + + msg_num_l = (sandesha2_last_msg_number_t *) msg_num; + return sandesha2_last_msg_number_free(msg_num_l, env); +} + +axis2_status_t AXIS2_CALL +sandesha2_last_msg_number_free ( + sandesha2_last_msg_number_t *last_msg_number, + const axutil_env_t *env) +{ + if(last_msg_number->ns_val) + { + AXIS2_FREE(env->allocator, last_msg_number->ns_val); + last_msg_number->ns_val = NULL; + } + + last_msg_number->msg_num = 0; + + AXIS2_FREE(env->allocator, last_msg_number); + return AXIS2_SUCCESS; +} + +axis2_char_t* AXIS2_CALL +sandesha2_last_msg_number_get_namespace_value( + sandesha2_last_msg_number_t *last_msg_number, + const axutil_env_t *env) +{ + return last_msg_number->ns_val; +} + + +void* AXIS2_CALL +sandesha2_last_msg_number_from_om_node( + sandesha2_last_msg_number_t *last_msg_number, + const axutil_env_t *env, + axiom_node_t *om_node) +{ + axiom_element_t *om_element = NULL; + axiom_element_t *mn_part = NULL; + axiom_node_t *mn_node = NULL; + axutil_qname_t *mn_qname = NULL; + axis2_char_t *mn_str = NULL; + + AXIS2_PARAM_CHECK(env->error, om_node, NULL); + + om_element = axiom_node_get_data_element(om_node, env); + if(!om_element) + { + AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_NULL_OM_ELEMENT, AXIS2_FAILURE); + return NULL; + } + + mn_qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_LAST_MSG_NUMBER, + last_msg_number->ns_val, NULL); + + if(!mn_qname) + { + return NULL; + } + + mn_part = axiom_element_get_first_child_with_qname(om_element, env, mn_qname, om_node, &mn_node); + if(mn_qname) + { + axutil_qname_free(mn_qname, env); + } + + if(!mn_part) + { + AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_NULL_OM_ELEMENT, AXIS2_FAILURE); + return NULL; + } + + mn_str = axiom_element_get_text(mn_part, env, mn_node); + if(!mn_str) + { + AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_EMPTY_OM_ELEMENT, AXIS2_FAILURE); + return NULL; + } + + last_msg_number->msg_num = atol(mn_str); + return last_msg_number; +} + + +axiom_node_t* AXIS2_CALL +sandesha2_last_msg_number_to_om_node( + sandesha2_last_msg_number_t *last_msg_number, + const axutil_env_t *env, void *om_node) +{ + axiom_namespace_t *rm_ns = NULL; + axiom_element_t *mn_element = NULL; + axiom_node_t *mn_node = NULL; + /*axis2_char_t *str_num = NULL;*/ + axis2_char_t str_num[32]; + + AXIS2_PARAM_CHECK(env->error, om_node, NULL); + + if(last_msg_number->msg_num <= 0) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "[sandesha2] Message number provided as last message number is invalid"); + + AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_TO_OM_INVALID_NUMBER, AXIS2_FAILURE); + return NULL; + } + + rm_ns = axiom_namespace_create(env, last_msg_number->ns_val, + SANDESHA2_WSRM_COMMON_NS_PREFIX_RM); + + if(!rm_ns) + { + return NULL; + } + + mn_element = axiom_element_create(env, NULL, SANDESHA2_WSRM_COMMON_LAST_MSG_NUMBER, rm_ns, + &mn_node); + + if(!mn_element) + { + return NULL; + } + + sprintf(str_num, "%ld", last_msg_number->msg_num); + axiom_element_set_text(mn_element, env, str_num, mn_node); + axiom_node_add_child((axiom_node_t*)om_node, env, mn_node); + + return (axiom_node_t*)om_node; + } + +long AXIS2_CALL +sandesha2_last_msg_number_get_last_msg_number( + sandesha2_last_msg_number_t *last_msg_number, + const axutil_env_t *env) +{ + return last_msg_number->msg_num; +} + +axis2_status_t AXIS2_CALL +sandesha2_last_msg_number_set_last_msg_number( + sandesha2_last_msg_number_t *last_msg_number, + const axutil_env_t *env, + long value) +{ + last_msg_number->msg_num = value; + return AXIS2_SUCCESS; +} + +static axis2_bool_t AXIS2_CALL +sandesha2_last_msg_number_is_namespace_supported( + const axutil_env_t *env, + axis2_char_t *namespace) +{ + if(!axutil_strcmp(namespace, SANDESHA2_SPEC_2005_02_NS_URI)) + { + return AXIS2_TRUE; + } + if(!axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI)) + { + return AXIS2_TRUE; + } + + return AXIS2_FALSE; +} + + --------------------------------------------------------------------- To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org For additional commands, e-mail: sandesha-dev-help@ws.apache.org