Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 38585 invoked from network); 6 Jul 2006 06:04:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Jul 2006 06:04:32 -0000 Received: (qmail 80526 invoked by uid 500); 6 Jul 2006 06:04:28 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 79847 invoked by uid 500); 6 Jul 2006 06:04:23 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 79816 invoked by uid 500); 6 Jul 2006 06:04:23 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 79807 invoked by uid 99); 6 Jul 2006 06:04:23 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Jul 2006 23:04:23 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Jul 2006 23:04:13 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 8C2261A983A; Wed, 5 Jul 2006 23:03:27 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r419452 [12/46] - in /webservices/axis2/trunk/c/woden: ./ include/ samples/ samples/wsdl10/ src/ src/builder/ src/builder/wsdl10/ src/schema/ src/types/ src/util/ src/wsdl/ src/wsdl/enumeration/ src/wsdl10/ src/wsdl10/enumeration/ src/wsdl1... Date: Thu, 06 Jul 2006 06:02:31 -0000 To: axis2-cvs@ws.apache.org From: damitha@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060706060327.8C2261A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Added: webservices/axis2/trunk/c/woden/src/builder/reader.c URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/woden/src/builder/reader.c?rev=419452&view=auto ============================================================================== --- webservices/axis2/trunk/c/woden/src/builder/reader.c (added) +++ webservices/axis2/trunk/c/woden/src/builder/reader.c Wed Jul 5 23:02:19 2006 @@ -0,0 +1,4042 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "../wsdl20/woden_constants.h" +#include "../util/woden_om_util.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +typedef struct woden_reader_impl woden_reader_impl_t; + +/** + * @brief Woden Wsdl Reader Struct Impl + * Woden Wsdl Reader + */ +struct woden_reader_impl +{ + woden_reader_t reader; + + axiom_document_t *om_doc; + axiom_node_t *root_node; + /* A map of imported schema definitions keyed by schema location URI */ + axis2_hash_t *f_imported_schemas; + woden_ext_registry_t *f_ext_reg; + axis2_uri_t *f_temp_uri; + +}; + +#define INTF_TO_IMPL(reader) ((woden_reader_impl_t *) reader) + +axis2_status_t AXIS2_CALL +woden_reader_free( + void *reader, + const axis2_env_t *env); + +void *AXIS2_CALL +woden_reader_read_wsdl( + void *reader, + const axis2_env_t *env, + axiom_document_t *om_doc, + const axis2_char_t *uri); + +axis2_status_t AXIS2_CALL +woden_reader_set_ext_registry( + void *reader, + const axis2_env_t *env, + woden_ext_registry_t *ext_reg); + +woden_ext_registry_t *AXIS2_CALL +woden_reader_get_ext_registry( + void *reader, + const axis2_env_t *env); + +/* Parse the attributes and child elements of the element. + * As per the WSDL 2.0 spec, the child elements must be in the + * following order if present: + * + * or WSDL extension elements in any order + * + * or WSDL extension elements in any order. + * TODO validate that the elements are in correct order + */ +static void * +parse_desc( + void *reader, + const axis2_env_t *env, + const axis2_char_t *document_base_uri, + axiom_node_t *desc_el_node, + axis2_hash_t *wsdl_modules); + +static void * +parse_documentation( + void *reader, + const axis2_env_t *env, + axiom_node_t *doc_el_node, + void *desc); + +static void * +parse_import( + void *reader, + const axis2_env_t *env, + axiom_node_t *import_el_node, + void *desc, + axis2_hash_t *wsdl_modules); + +static void * +parse_include( + void *reader, + const axis2_env_t *env, + axiom_node_t *include_el_node, + void *desc, + axis2_hash_t *wsdl_modules); + +/* + * TODO Initial schema parsing is specific to XML Schema. + * Need generic support for other type systems. + * Consider extension architecture with serializer/deserializer. + */ + +static void * +parse_types( + void *reader, + const axis2_env_t *env, + axiom_node_t *types_el_node, + void *desc); + +static void * +parse_schema_inline( + void *reader, + const axis2_env_t *env, + axiom_node_t *schema_el_node, + void *desc); + +/* + * Parse the <xs:import> element and retrieve the imported + * schema document if schemaLocation specified. Failure to retrieve + * the schema will only matter if any WSDL components contain elements or + * constraints that refer to the schema, and typically this will be + * determined later by WSDL validation. So just report any such errors + * and return the Schema Import object (i.e. with a null schema property). + * + * WSDL 2.0 spec validation: + * - namespace attribute is REQUIRED + * - imported schema MUST have a targetNamespace + * - namespace and targetNamespace MUST be the same + */ +static void * +parse_schema_import( + void *reader, + const axis2_env_t *env, + axiom_node_t *import_el_node, + void *desc); + +static void * +parse_interface( + void *reader, + const axis2_env_t *env, + axiom_node_t *interface_el_node, + void *desc); + +/* Parse the attributes and child elements of interface . + * As per WSDL 2.0 spec, the child elements must be in the following order if present: + * + * or extension elements in any order + * + * TODO validate that the elements are in correct order + */ +static void * +parse_interface_fault( + void *reader, + const axis2_env_t *env, + axiom_node_t *fault_el_node, + void *desc, + void *parent); + +static void * +parse_interface_op( + void *reader, + const axis2_env_t *env, + axiom_node_t *op_el_node, + void *desc, + void *parent); + +static void * +parse_interface_fault_ref( + void *reader, + const axis2_env_t *env, + axiom_node_t *fault_ref_el_node, + void *desc, + void *parent); + +static void * +parse_interface_msg_ref( + void *reader, + const axis2_env_t *env, + axiom_node_t *msg_ref_el_node, + void *desc, + void *parent); + +static void * +parse_binding( + void *reader, + const axis2_env_t *env, + axiom_node_t *binding_el_node, + void *desc); + +static void * +parse_binding_fault( + void *reader, + const axis2_env_t *env, + axiom_node_t *fault_el_node, + void *desc, + void *parent); + +static void * +parse_binding_op( + void *reader, + const axis2_env_t *env, + axiom_node_t *op_el_node, + void *desc, + void *parent); + +static void * +parse_binding_fault_ref( + void *reader, + const axis2_env_t *env, + axiom_node_t *fault_ref_el_node, + void *desc, + void *parent); + +static void * +parse_binding_msg_ref( + void *reader, + const axis2_env_t *env, + axiom_node_t *msg_ref_el_node, + void *desc, + void *parent); + +static void * +parse_svc( + void *reader, + const axis2_env_t *env, + axiom_node_t *svc_el_node, + void *desc); + +static void * +parse_endpoint( + void *reader, + const axis2_env_t *env, + axiom_node_t *endpoint_el_node, + void *desc, + void *parent); + +static void * +parse_feature( + void *reader, + const axis2_env_t *env, + axiom_node_t *feature_el_node, + void *desc, + void *parent); + +/* ****************************************************************** + * Parse the attributes and child elements of the element. + * + * As per WSDL 2.0 spec, they must be in the following order if present: + * + * or + * extension elements. + * + * TODO validate that the elements are in correct order + * + * Child elements may include either a or a , + * but not both. If a element is present, a + * may only be present if it contains the NMToken "#value", which + * indicates that this specifies a value, not a constraint. + * + * This method will parse all child elements of without + * checking for any erroneous use of and . + * This will be done later by validation, if it's enabled. + * If the NMToken "#value" is present in a element, + * this will be flagged with a boolean field in PropertyElement + * and the constraint field will be set to null. + * + */ + +static void * +parse_property( + void *reader, + const axis2_env_t *env, + axiom_node_t *property_el_node, + void *desc, + void *parent); + +axis2_status_t AXIS2_CALL +parse_ext_attributes( + void *reader, + const axis2_env_t *env, + axiom_node_t *om_el_node, + axis2_char_t *wsdl_class, + void *wsdl_obj, + void *desc); + +static void * +parse_ext_element( + void *reader, + const axis2_env_t *env, + axis2_char_t *parent_type, + void *parent, + axiom_node_t *el_node, + void *desc); + +/* ************************************************************ + * Utility/helper methods + * ************************************************************/ + +/** + * Check the actual element encountered against the expected qname + * + * @param el actual element encountered + * @param qname expected element's qname + */ +static axis2_status_t +check_element_qname( + void *reader, + const axis2_env_t *env, + axiom_node_t *el_node, + axis2_qname_t *qname); + +/* + * Retrieve a WSDL document by resolving the location URI specified + * on a WSDL <import> or <include> element. + * + * TODO add support for a URL Catalog Resolver + */ +static void * +get_wsdl_from_location( + void *reader, + const axis2_env_t *env, + axis2_char_t *location_uri_str, + void *desc, + axis2_hash_t *wsdl_modules); + +/* + * Convert a string of type xs:anyURI to a axis2_uri. + * An empty string argument will return an empty string URI. + * A null argument will return a null. + */ +static axis2_uri_t * +get_uri( + void *reader, + const axis2_env_t *env, + const axis2_char_t *uri_str); + +static woden_reader_t * +create( + const axis2_env_t *env) +{ + woden_reader_impl_t *reader_impl = NULL; + + AXIS2_ENV_CHECK(env, NULL); + reader_impl = AXIS2_MALLOC(env->allocator, + sizeof(woden_reader_impl_t)); + + reader_impl->f_imported_schemas = NULL; + reader_impl->f_ext_reg = NULL; + reader_impl->f_temp_uri = NULL; + + reader_impl->reader.ops = AXIS2_MALLOC(env->allocator, + sizeof(woden_reader_ops_t)); + + reader_impl->f_imported_schemas = axis2_hash_make(env); + if(!reader_impl->f_imported_schemas) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + reader_impl->reader.ops->free = woden_reader_free; + reader_impl->reader.ops->read_wsdl = woden_reader_read_wsdl; + reader_impl->reader.ops->set_ext_registry = woden_reader_set_ext_registry; + reader_impl->reader.ops->get_ext_registry = woden_reader_get_ext_registry; + + return &(reader_impl->reader); +} + +AXIS2_EXTERN woden_reader_t * AXIS2_CALL +woden_reader_create( + const axis2_env_t *env) +{ + woden_reader_impl_t *reader_impl = NULL; + + AXIS2_ENV_CHECK(env, NULL); + reader_impl = (woden_reader_impl_t *) create(env); + + return &(reader_impl->reader); +} + +axis2_status_t AXIS2_CALL +woden_reader_free( + void *reader, + const axis2_env_t *env) +{ + woden_reader_impl_t *reader_impl = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + reader_impl = INTF_TO_IMPL(reader); + + if(reader_impl->f_imported_schemas) + { + axis2_hash_free(reader_impl->f_imported_schemas, env); + reader_impl->f_imported_schemas = NULL; + } + + if(reader_impl->f_temp_uri) + { + AXIS2_URI_FREE(reader_impl->f_temp_uri, env); + reader_impl->f_temp_uri = NULL; + } + + if(reader_impl->f_ext_reg) + { + WODEN_EXT_REGISTRY_FREE(reader_impl->f_ext_reg, env); + reader_impl->f_ext_reg = NULL; + } + + if((&(reader_impl->reader))->ops) + { + AXIS2_FREE(env->allocator, (&(reader_impl->reader))->ops); + (&(reader_impl->reader))->ops = NULL; + } + + if(reader_impl) + { + AXIS2_FREE(env->allocator, reader_impl); + reader_impl = NULL; + } + return AXIS2_SUCCESS; +} + +/* ************************************************************ + * API public methods + * ************************************************************/ +axis2_status_t AXIS2_CALL +woden_reader_set_ext_registry( + void *reader, + const axis2_env_t *env, + woden_ext_registry_t *ext_reg) +{ + woden_reader_impl_t *reader_impl = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, ext_reg, AXIS2_FAILURE); + reader_impl = INTF_TO_IMPL(reader); + + if(reader_impl->f_ext_reg) + { + WODEN_EXT_REGISTRY_FREE(reader_impl->f_ext_reg, env); + reader_impl->f_ext_reg = NULL; + } + reader_impl->f_ext_reg = ext_reg; + return AXIS2_SUCCESS; +} + +woden_ext_registry_t *AXIS2_CALL +woden_reader_get_ext_registry( + void *reader, + const axis2_env_t *env) +{ + woden_reader_impl_t *reader_impl = NULL; + + AXIS2_ENV_CHECK(env, NULL); + reader_impl = INTF_TO_IMPL(reader); + + return reader_impl->f_ext_reg; +} + +void *AXIS2_CALL +woden_reader_read_wsdl( + void *reader, + const axis2_env_t *env, + axiom_document_t *om_doc, + const axis2_char_t *uri) +{ + woden_reader_impl_t *reader_impl = NULL; + void *desc = NULL; + + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, om_doc, NULL); + AXIS2_PARAM_CHECK(env->error, uri, NULL); + reader_impl = INTF_TO_IMPL(reader); + + /* TODO add WSDL locator for resolving URIs */ + reader_impl->om_doc = om_doc; + reader_impl->root_node = AXIOM_DOCUMENT_GET_ROOT_ELEMENT(om_doc, env); + if(!reader_impl->root_node) + return NULL; + desc = parse_desc(reader, env, uri, reader_impl->root_node, NULL); + + /* TODO Validate the model if validation is enabled. */ + + return desc; +} + +/* ************************************************************ + * Parsing methods - e.g. parse_xxxx() + * ************************************************************/ + +/* Parse the attributes and child elements of the element. + * As per the WSDL 2.0 spec, the child elements must be in the + * following order if present: + * + * or WSDL extension elements in any order + * + * or WSDL extension elements in any order. + * TODO validate that the elements are in correct order + */ +static void * +parse_desc( + void *reader, + const axis2_env_t *env, + const axis2_char_t *document_base_uri, + axiom_node_t *desc_el_node, + axis2_hash_t *wsdl_modules) +{ + woden_reader_impl_t *reader_impl = NULL; + void *desc = NULL; + void *ext_reg = NULL; + axis2_uri_t *uri = NULL; + axis2_char_t *target_namespc = NULL; + axis2_uri_t *target_namespc_uri = NULL; + axiom_element_t *desc_el = NULL; + axis2_hash_t *attrs = NULL; + axis2_hash_index_t *index = NULL; + axiom_element_t *temp_el = NULL; + axiom_node_t *temp_el_node = NULL; + void *types = NULL; + axis2_qname_t *qname = NULL; + void *schema = NULL; + axiom_attribute_t *attr_ns = NULL; + axiom_attribute_t *attr_loc = NULL; + axiom_element_t *schema_elem = NULL; + axiom_node_t *schema_elem_node = NULL; + axiom_namespace_t *schema_ns = NULL; + axis2_status_t status = AXIS2_FAILURE; + + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, document_base_uri, NULL); + AXIS2_PARAM_CHECK(env->error, desc_el_node, NULL); + reader_impl = INTF_TO_IMPL(reader); + + qname = axis2_qname_create_from_string(env, WODEN_Q_ELEM_DESCRIPTION); + check_element_qname(reader, env, desc_el_node, qname); + + desc = woden_desc_create(env); + ext_reg = woden_ext_registry_create(env); + desc = woden_desc_to_desc_element(desc, env); + WODEN_DESC_ELEMENT_SET_EXT_REGISTRY(desc, env, ext_reg); + + if(NULL == wsdl_modules) + { + /* This is the initial WSDL document. No imports or includes yet. + * TODO this might be the place to flag the initial Desc if necessary. + */ + wsdl_modules = axis2_hash_make(env); + } + ext_reg = woden_reader_get_ext_registry(reader, env); + if(NULL != ext_reg) + { + WODEN_DESC_ELEMENT_SET_EXT_REGISTRY(desc, env, ext_reg); + } + + uri = get_uri(reader, env, document_base_uri); + WODEN_DESC_ELEMENT_SET_DOCUMENT_BASE_URI(desc, env, uri); + + desc_el = AXIOM_NODE_GET_DATA_ELEMENT(desc_el_node, env); + target_namespc = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(desc_el, + env, WODEN_ATTR_TARGET_NAMESPACE); + + if(NULL != target_namespc) + { + target_namespc_uri = get_uri(reader, env, target_namespc); + WODEN_DESC_ELEMENT_SET_TARGET_NAMESPACE(desc, env, target_namespc_uri); + } + + /* parse the namespace declarations */ + attrs = AXIOM_ELEMENT_GET_ALL_ATTRIBUTES(desc_el, env); + for (index = axis2_hash_first (attrs, env); index; index = axis2_hash_next ( + env, index)) + { + void *v = NULL; + axiom_attribute_t *attr = NULL; + axiom_namespace_t *namespc = NULL; + axis2_char_t *namespc_uri = NULL; + axis2_char_t *local_part = NULL; + axis2_char_t *value = NULL; + + axis2_hash_this (index, NULL, NULL, &v); + attr = (axiom_attribute_t *) v; + namespc = AXIOM_ATTRIBUTE_GET_NAMESPACE(attr, env); + if(!namespc) + continue; + namespc_uri = AXIOM_NAMESPACE_GET_URI(namespc, env); + local_part = AXIOM_ATTRIBUTE_GET_LOCALNAME(attr, env); + value = AXIOM_ATTRIBUTE_GET_VALUE(attr, env); + uri = get_uri(reader, env, value); + if(0 == AXIS2_STRCMP(WODEN_NS_URI_XMLNS, namespc_uri)) + { + if(0 == AXIS2_STRCMP(WODEN_ATTR_XMLNS, local_part)) + { + WODEN_DESC_ELEMENT_ADD_NAMESPACE(desc, env, local_part, uri); + /* a prefixed namespace */ + } + else + { + WODEN_DESC_ELEMENT_ADD_NAMESPACE(desc, env, NULL, uri); + } + } + + } + desc = woden_desc_to_attr_extensible(desc, env); + status = parse_ext_attributes(reader, env, desc_el_node, "description_element", desc, desc); + if(AXIS2_SUCCESS != status) + return NULL; + + /* Parse the child elements */ + temp_el = axiom_util_get_first_child_element(desc_el, env, desc_el_node, + &temp_el_node); + + while (NULL != temp_el && NULL != temp_el_node) + { + axis2_qname_t *q_elem_documentation = NULL; + axis2_qname_t *q_elem_import = NULL; + axis2_qname_t *q_elem_include = NULL; + axis2_qname_t *q_elem_types = NULL; + axis2_qname_t *q_elem_interface = NULL; + axis2_qname_t *q_elem_binding = NULL; + axis2_qname_t *q_elem_svc = NULL; + + q_elem_documentation = axis2_qname_create_from_string(env, WODEN_Q_ELEM_DOCUMENTATION); + q_elem_import = axis2_qname_create_from_string(env, WODEN_Q_ELEM_IMPORT); + q_elem_include = axis2_qname_create_from_string(env, WODEN_Q_ELEM_INCLUDE); + q_elem_types = axis2_qname_create_from_string(env, WODEN_Q_ELEM_TYPES); + q_elem_interface = axis2_qname_create_from_string(env, WODEN_Q_ELEM_INTERFACE); + q_elem_binding = axis2_qname_create_from_string(env, WODEN_Q_ELEM_BINDING); + q_elem_svc = axis2_qname_create_from_string(env, WODEN_Q_ELEM_SERVICE); + + if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_documentation, temp_el_node)) + { + void *documentation = NULL; + + documentation = parse_documentation(reader, env, temp_el_node, desc); + + desc = woden_desc_to_documentable(desc, env); + WODEN_DOCUMENTABLE_ADD_DOCUMENTATION_ELEMENT(desc, env, documentation); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_import, temp_el_node)) + { + void *import_element = NULL; + + if(NULL != document_base_uri && AXIS2_TRUE != + axis2_hash_contains_key(wsdl_modules, env, + document_base_uri)) + { + axis2_hash_set(wsdl_modules, document_base_uri, + AXIS2_HASH_KEY_STRING, desc); + } + import_element = parse_import(reader, env, temp_el_node, desc, + wsdl_modules); + desc = woden_desc_to_desc_element(desc, env); + WODEN_DESC_ELEMENT_ADD_IMPORT_ELEMENT(desc, env, import_element); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_include, temp_el_node)) + { + void *include_element = NULL; + + if(NULL != document_base_uri && AXIS2_TRUE != + axis2_hash_contains_key(wsdl_modules, env, + document_base_uri)) + { + axis2_hash_set(wsdl_modules, document_base_uri, + AXIS2_HASH_KEY_STRING, desc); + } + include_element = parse_include(reader, env, temp_el_node, desc, + wsdl_modules); + WODEN_DESC_ELEMENT_ADD_INCLUDE_ELEMENT(desc, env, include_element); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_types, temp_el_node)) + { + void *types = NULL; + + types = parse_types(reader, env, temp_el_node, desc); + WODEN_DESC_ELEMENT_SET_TYPES_ELEMENT(desc, env, types); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_interface, temp_el_node)) + { + void *interface = NULL; + + interface = parse_interface(reader, env, temp_el_node, desc); + WODEN_DESC_ELEMENT_ADD_INTERFACE_ELEMENT(desc, env, interface); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_binding, temp_el_node)) + { + void *binding = NULL; + + binding = parse_binding(reader, env, temp_el_node, desc); + WODEN_DESC_ELEMENT_ADD_BINDING_ELEMENT(desc, env, binding); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_svc, temp_el_node)) + { + void *svc = NULL; + + svc = parse_svc(reader, env, temp_el_node, desc); + WODEN_DESC_ELEMENT_ADD_SVC_ELEMENT(desc, env, svc); + } + else + { + void *ext_element = NULL; + + ext_element = parse_ext_element(reader, env, "desc_element", desc, temp_el_node, desc); + desc = woden_desc_to_element_extensible(desc, env); + WODEN_ELEMENT_EXTENSIBLE_ADD_EXT_ELEMENT(desc, env, ext_element); + } + + temp_el = axiom_util_get_next_sibling_element(temp_el, env, + temp_el_node, &temp_el_node); + } + + /* + * Parse the schema for schema to include the built in schema types in the Woden model. + * TODO: As there are a finite number of built in schema types it may be better to create + * constants rather than reading the schema for schema on the creation of every model. + * Also, this method currently requires that the schema elements exist in the types element. + * This may not be the best idea as it may imply that this schema contains an actual import + * statement in a WSDL 2.0 document. This method also does not work for when building the + * model programmatically. + * This method should be reevaluated at a later point. + */ + desc = woden_desc_to_desc_element(desc, env); + types = WODEN_DESC_ELEMENT_GET_TYPES_ELEMENT(desc, env); + if(NULL == types) + { + + types = WODEN_DESC_ELEMENT_CREATE_TYPES_ELEMENT(desc, env); + types = woden_types_to_types_element(types, env); + WODEN_TYPES_ELEMENT_SET_TYPE_SYSTEM(types, env, WODEN_TYPE_XSD_2001); + WODEN_DESC_ELEMENT_SET_TYPES_ELEMENT(desc, env, types); + } + schema_ns = axiom_namespace_create(env, + "http://www.w3.org/2001/XMLSchema", "import"); + schema_elem = axiom_element_create(env, desc_el_node, "import", + schema_ns, &schema_elem_node); + attr_ns = axiom_attribute_create(env, "namespace", + "http://www.w3.org/2001/XMLSchema", NULL); + attr_loc = axiom_attribute_create(env, "schemaLocation", + "http://www.w3.org/2001/XMLSchema.xsd", NULL); + AXIOM_ELEMENT_ADD_ATTRIBUTE(schema_elem, env, attr_ns, schema_elem_node); + AXIOM_ELEMENT_ADD_ATTRIBUTE(schema_elem, env, attr_loc, schema_elem_node); + + schema = parse_schema_import(reader, env, schema_elem_node, desc); + if(schema) + { + types = woden_types_to_types_element(types, env); + schema = woden_imported_schema_to_schema(schema, env); + WODEN_TYPES_ELEMENT_ADD_SCHEMA(types, env, schema); + } + return desc; +} + +static void * +parse_documentation( + void *reader, + const axis2_env_t *env, + axiom_node_t *doc_el_node, + void *desc) +{ + void *documentation = NULL; + axiom_element_t *doc_el = NULL; + axiom_element_t *temp_el = NULL; + axiom_node_t *temp_el_node = NULL; + axis2_status_t status = AXIS2_FAILURE; + + desc = woden_desc_to_desc_element(desc, env); + documentation = WODEN_DESC_ELEMENT_CREATE_DOCUMENTATION_ELEMENT(desc, + env); + + /* TODO store doc_el as below, or just extract any text? */ + documentation = woden_documentation_to_documentation_element( + documentation, env); + WODEN_DOCUMENTATION_ELEMENT_SET_CONTENT(documentation, env, doc_el_node); + + /* Now parse any extensibility attributes or elements */ + documentation = woden_documentation_to_attr_extensible(documentation, + env); + status = parse_ext_attributes(reader, env, doc_el_node, "documentation_element", + documentation, desc); + if(AXIS2_SUCCESS != status) + return NULL; + + doc_el = AXIOM_NODE_GET_DATA_ELEMENT(doc_el_node, env); + temp_el = axiom_util_get_first_child_element(doc_el, env, doc_el_node, + &temp_el_node); + + while (NULL != temp_el) + { + void *ext_el = NULL; + + ext_el = parse_ext_element(reader, env, "documentation_element", + documentation, temp_el_node, desc); + documentation = woden_documentation_to_element_extensible( + documentation, env); + WODEN_ELEMENT_EXTENSIBLE_ADD_EXT_ELEMENT(documentation, env, + ext_el); + temp_el = axiom_util_get_next_sibling_element(temp_el, env, + temp_el_node, &temp_el_node); + } + + return documentation; +} + +static void * +parse_import( + void *reader, + const axis2_env_t *env, + axiom_node_t *import_el_node, + void *desc, + axis2_hash_t *wsdl_modules) +{ + void *imp = NULL; + axiom_element_t *import_el = NULL; + axis2_char_t *namespc_uri = NULL; + axis2_char_t *location_uri = NULL; + axis2_status_t status = AXIS2_FAILURE; + + imp = WODEN_DESC_ELEMENT_CREATE_IMPORT_ELEMENT(desc, env); + import_el = AXIOM_NODE_GET_DATA_ELEMENT(import_el_node, env); + + namespc_uri = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(import_el, env, + WODEN_ATTR_NAMESPACE); + location_uri = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(import_el, env, + WODEN_ATTR_LOCATION); + + imp = woden_import_to_attr_extensible(imp, env); + status = parse_ext_attributes(reader, env, import_el_node, "import_element", imp, desc); + if(AXIS2_SUCCESS != status) + return NULL; + + if(NULL != namespc_uri) + { + axis2_uri_t *uri = NULL; + + /* TODO handle missing namespace attribute (REQUIRED attr) */ + uri = get_uri(reader, env, namespc_uri); + WODEN_IMPORT_SET_NAMESPACE(imp, env, uri); + } + + if(NULL != location_uri) + { + axis2_uri_t *uri = NULL; + void *imported_desc = NULL; + + /* TODO handle missing locationURI (OPTIONAL attr) */ + imp = woden_import_to_import_element(imp, env); + uri = get_uri(reader, env, location_uri); + WODEN_IMPORT_ELEMENT_SET_LOCATION(imp, env, uri); + + imported_desc = get_wsdl_from_location(reader, env, location_uri, desc, + wsdl_modules); + WODEN_IMPORT_ELEMENT_SET_DESC_ELEMENT(imp, env, imported_desc); + } + + return imp; +} + +static void * +parse_include( + void *reader, + const axis2_env_t *env, + axiom_node_t *include_el_node, + void *desc, + axis2_hash_t *wsdl_modules) +{ + void *include = NULL; + axiom_element_t *include_el = NULL; + axis2_char_t *location_uri = NULL; + axis2_status_t status = AXIS2_FAILURE; + + include = WODEN_DESC_ELEMENT_CREATE_INCLUDE_ELEMENT(desc, env); + include_el = AXIOM_NODE_GET_DATA_ELEMENT(include_el_node, env); + + location_uri = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(include_el, env, + WODEN_ATTR_LOCATION); + + include = woden_include_to_attr_extensible(include, env); + status = parse_ext_attributes(reader, env, include_el_node, "include_element", + include, desc); + if(AXIS2_SUCCESS != status) + return NULL; + + if(NULL != location_uri) + { + axis2_uri_t *uri = NULL; + void *included_desc = NULL; + + uri = get_uri(reader, env, location_uri); + include = woden_include_to_include_element(include, env); + WODEN_INCLUDE_ELEMENT_SET_LOCATION(include, env, uri); + + included_desc = get_wsdl_from_location(reader, env, location_uri, desc, + wsdl_modules); + WODEN_INCLUDE_ELEMENT_SET_DESC_ELEMENT(include, env, included_desc); + } + + return include; +} + +/* + * TODO Initial schema parsing is specific to XML Schema. + * Need generic support for other type systems. + * Consider extension architecture with serializer/deserializer. + */ + +static void * +parse_types( + void *reader, + const axis2_env_t *env, + axiom_node_t *types_el_node, + void *desc) +{ + void *types = NULL; + axiom_element_t *types_el = NULL; + axiom_element_t *temp_el = NULL; + axiom_node_t *temp_el_node = NULL; + axis2_status_t status = AXIS2_FAILURE; + + desc = woden_desc_to_desc_element(desc, env); + types = WODEN_DESC_ELEMENT_CREATE_TYPES_ELEMENT(desc, env); + types = woden_types_to_types_element(types, env); + WODEN_TYPES_ELEMENT_SET_TYPE_SYSTEM(types, env, WODEN_TYPE_XSD_2001); + + types = woden_types_to_attr_extensible(types, env); + status = parse_ext_attributes(reader, env, types_el_node, "types_element", + types, desc); + if(AXIS2_SUCCESS != status) + return NULL; + + types_el = AXIOM_NODE_GET_DATA_ELEMENT(types_el_node, env); + temp_el = axiom_util_get_first_child_element(types_el, env, types_el_node, + &temp_el_node); + + while (NULL != temp_el && NULL != temp_el_node) + { + axis2_qname_t *q_elem_documentation = NULL; + axis2_qname_t *q_temp_el_type = NULL; + + q_temp_el_type = axis2_qname_util_new_qname(env, temp_el_node); + q_elem_documentation = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_DOCUMENTATION); + + if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_documentation, temp_el_node)) + { + void *documentation = NULL; + + documentation = parse_documentation(reader, env, temp_el_node, desc); + types = woden_types_to_documentable(types, env); + WODEN_DOCUMENTABLE_ADD_DOCUMENTATION_ELEMENT(types, env, documentation); + } + if(AXIS2_TRUE == woden_schema_constants_compare_import(q_temp_el_type, env)) + { + void *schema = NULL; + + schema = parse_schema_import(reader, env, temp_el_node, desc); + if(schema) + { + types = woden_types_to_types_element(types, env); + schema = woden_imported_schema_to_schema(schema, env); + WODEN_TYPES_ELEMENT_ADD_SCHEMA(types, env, schema); + } + } + if(AXIS2_TRUE == woden_schema_constants_compare_schema(q_temp_el_type, env)) + { + void *schema = NULL; + + schema = parse_schema_inline(reader, env, temp_el_node, desc); + if(schema) + { + types = woden_types_to_types_element(types, env); + schema = woden_inlined_schema_to_schema(schema, env); + WODEN_TYPES_ELEMENT_ADD_SCHEMA(types, env, schema); + } + } + else + { + void *ext_element = NULL; + + ext_element = parse_ext_element(reader, env, "types_element", + types, temp_el_node, desc); + types = woden_types_to_element_extensible(types, env); + WODEN_ELEMENT_EXTENSIBLE_ADD_EXT_ELEMENT(types, env, ext_element); + } + + temp_el = axiom_util_get_next_sibling_element(temp_el, env, + temp_el_node, &temp_el_node); + } + + return types; +} + +static void * +parse_schema_inline( + void *reader, + const axis2_env_t *env, + axiom_node_t *schema_el_node, + void *desc) +{ + void *schema = woden_inlined_schema_create(env); + axis2_char_t *attr_id = NULL; + axis2_char_t *tns = NULL; + axis2_uri_t *base_uri = NULL; + axis2_char_t *base_uri_str = NULL; + xml_schema_t *schema_def = NULL; + xml_schema_collection_t *xsc = NULL; + axiom_element_t *schema_el = NULL; + + schema_el = AXIOM_NODE_GET_DATA_ELEMENT(schema_el_node, env); + attr_id = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(schema_el, env, + WODEN_ATTR_ID); + WODEN_INLINED_SCHEMA_SET_ID(schema, env, attr_id); + tns = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(schema_el, env, + WODEN_ATTR_TARGET_NAMESPACE); + + if(NULL != tns) + { + void *base = WODEN_INLINED_SCHEMA_GET_BASE_IMPL(schema, env); + axis2_uri_t *uri = get_uri(reader, env, tns); + WODEN_SCHEMA_SET_NAMESPACE(base, env, uri); + } + desc = woden_desc_to_desc_element(desc, env); + base_uri = WODEN_DESC_ELEMENT_GET_DOCUMENT_BASE_URI(desc, env); + if(base_uri) + base_uri_str = AXIS2_URI_TO_STRING(base_uri, env, + AXIS2_URI_UNP_OMITUSERINFO); + + xsc = xml_schema_collection_create(env); + /* TODO Temporarily assume that imported schemas are stored as files + * with the url as file name + */ + schema_def = XML_SCHEMA_COLLECTION_READ_ELEMENT_WITH_URI(xsc, + env, schema_el_node, base_uri_str); + if(AXIS2_SUCCESS != AXIS2_ERROR_GET_STATUS_CODE(env->error)) + { + return NULL; + } + if(schema_def) + { + void *base_schema = NULL; + + base_schema = WODEN_INLINED_SCHEMA_GET_BASE_IMPL(schema, env); + WODEN_SCHEMA_SET_REFERENCEABLE(base_schema, env, AXIS2_TRUE); + WODEN_SCHEMA_SET_SCHEMA_DEF(base_schema, env, schema_def); + } + else + { + void *base_schema = NULL; + + base_schema = WODEN_INLINED_SCHEMA_GET_BASE_IMPL(schema, env); + WODEN_SCHEMA_SET_REFERENCEABLE(base_schema, env, AXIS2_FALSE); + } + + return schema; +} + +/* + * Parse the <xs:import> element and retrieve the imported + * schema document if schemaLocation specified. Failure to retrieve + * the schema will only matter if any WSDL components contain elements or + * constraints that refer to the schema, and typically this will be + * determined later by WSDL validation. So just report any such errors + * and return the Schema Import object (i.e. with a null schema property). + * + * WSDL 2.0 spec validation: + * - namespace attribute is REQUIRED + * - imported schema MUST have a targetNamespace + * - namespace and targetNamespace MUST be the same + */ +static void * +parse_schema_import( + void *reader, + const axis2_env_t *env, + axiom_node_t *import_el_node, + void *desc) +{ + woden_reader_impl_t *reader_impl = NULL; + void *schema = NULL; + axis2_char_t *ns = NULL; + axis2_char_t *sloc = NULL; + axis2_char_t *schema_uri = NULL; + axis2_uri_t *uri = NULL; + void *schema_def = NULL; + axis2_uri_t *context_uri = NULL; + axis2_char_t *schema_loc = NULL; + axiom_element_t *import_el = NULL; + + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, desc, NULL); + reader_impl = INTF_TO_IMPL(reader); + + schema = woden_imported_schema_create(env); + if(!schema) + return NULL; + import_el = AXIOM_NODE_GET_DATA_ELEMENT(import_el_node, env); + ns = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(import_el, env, + WODEN_ATTR_NAMESPACE); + if(NULL != ns) + { + uri = get_uri(reader, env, ns); + schema = woden_imported_schema_to_schema(schema, env); + WODEN_SCHEMA_SET_NAMESPACE(schema, env, uri); + } + sloc = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(import_el, env, + WODEN_ATTR_SCHEMA_LOCATION); + if(NULL != sloc) + { + uri = get_uri(reader, env, sloc); + WODEN_IMPORTED_SCHEMA_SET_LOCATION(schema, env, uri); + } + + if(NULL == WODEN_SCHEMA_GET_NAMESPACE(schema, env)) + { + /* The namespace attribute is REQUIRED on xs:import, so don't continue. */ + WODEN_SCHEMA_SET_REFERENCEABLE(schema, env, AXIS2_FALSE); + return schema; + } + + if(NULL == WODEN_IMPORTED_SCHEMA_GET_LOCATION(schema, env)) + { + /* This is a namespace-only import, no schema document to be retrieved so don't continue.*/ + + /* TODO investigate whether/how to try to resolve the imported namespace to known schema + * components from that namespace (e.g. via a URI catalog resolver). Currently, any attempt + * to resolve a QName against schema components from this namespace will search ALL + * schemas imported from this namespace (see methods in TypesImpl). + */ + + return schema; + } + + /* Now try to retrieve the schema import using schemaLocation */ + desc = woden_desc_to_desc_element(desc, env); + context_uri = WODEN_DESC_ELEMENT_GET_DOCUMENT_BASE_URI(desc, env); + uri = WODEN_IMPORTED_SCHEMA_GET_LOCATION(schema, env); + schema_loc = AXIS2_URI_TO_STRING(uri, env, AXIS2_URI_UNP_OMITUSERINFO); + uri = axis2_uri_parse_relative(env, context_uri, schema_loc); + if(AXIS2_SUCCESS != AXIS2_ERROR_GET_STATUS_CODE(env->error)) + { + /* can't continue schema retrieval with a bad URL.*/ + WODEN_SCHEMA_SET_REFERENCEABLE(schema, env, AXIS2_FALSE); + return schema; + } + + schema_uri = AXIS2_URI_TO_STRING(uri, env, AXIS2_URI_UNP_OMITUSERINFO); + + /* If the schema has already been imported, reuse it. */ + schema_def = axis2_hash_get(reader_impl->f_imported_schemas, schema_uri, + AXIS2_HASH_KEY_STRING); + if(NULL != schema_def) + { + /* Not previously imported, so retrieve it now. */ + xml_schema_collection_t *schema_col = NULL; + axiom_xml_reader_t *xml_reader = NULL; + axiom_document_t *imported_schema_doc = NULL; + axiom_stax_builder_t *xml_builder = NULL; + + schema_col = xml_schema_collection_create(env); + /* TODO Temporarily assume that imported schemas are stored as files + * with the url as file name + */ + xml_reader = axiom_xml_reader_create_for_file(env, schema_uri, NULL); + xml_builder = axiom_stax_builder_create(env, reader); + imported_schema_doc = axiom_document_create(env, NULL, xml_builder); + schema_def = XML_SCHEMA_COLLECTION_READ_DOCUMENT(schema_col, + env, imported_schema_doc); + if(AXIS2_SUCCESS != AXIS2_ERROR_GET_STATUS_CODE(env->error)) + { + WODEN_SCHEMA_SET_REFERENCEABLE(schema, env, AXIS2_FALSE); + return schema; + } + axis2_hash_set(reader_impl->f_imported_schemas, schema_uri, + AXIS2_HASH_KEY_STRING, schema_def); + + } + + if(NULL != schema_def) + { + WODEN_SCHEMA_SET_SCHEMA_DEF(schema, env, schema_def); + } else + { + WODEN_SCHEMA_SET_REFERENCEABLE(schema, env, AXIS2_FALSE); + } + + return schema; +} + +static void * +parse_interface( + void *reader, + const axis2_env_t *env, + axiom_node_t *interface_el_node, + void *desc) +{ + void *intface = NULL; + axis2_char_t *name = NULL; + axis2_char_t *style_default = NULL; + axiom_element_t *interface_el = NULL; + axiom_element_t *temp_el = NULL; + axiom_node_t *temp_el_node = NULL; + axis2_status_t status = AXIS2_FAILURE; + + desc = woden_desc_to_desc_element(desc, env); + intface = WODEN_DESC_ELEMENT_CREATE_INTERFACE_ELEMENT(desc, env); + + interface_el = AXIOM_NODE_GET_DATA_ELEMENT(interface_el_node, env); + name = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(interface_el, env, WODEN_ATTR_NAME); + +/* + * + * |----------| ---- ---- ------------| + * |--- ---| | | | | | |--------| + * | | | | | | | | + * | | | | | | | | + * | | | --------- | | -----| + * | | | --------- | | -----| + * | | | | | | | | + * | | | | | | | | + * | | | | | | | |--------| + * ---- ---- ---- ------------| + * + * + */ + + if(NULL != name) + { + axis2_qname_t *qname = NULL; + axis2_uri_t *namespc = NULL; + axis2_char_t *namespc_str = NULL; + + namespc = WODEN_DESC_ELEMENT_GET_TARGET_NAMESPACE(desc, env); + namespc_str = AXIS2_URI_TO_STRING(namespc, env, AXIS2_URI_UNP_OMITUSERINFO); + qname = axis2_qname_create(env, name, namespc_str, NULL); + intface = woden_interface_to_interface_element(intface, env); + WODEN_INTERFACE_ELEMENT_SET_QNAME(intface, env, qname); + } + + style_default = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(interface_el, + env, WODEN_ATTR_STYLE_DEFAULT); + + if(NULL != style_default) + { + axis2_array_list_t *string_list = NULL; + axis2_char_t *uri_str = NULL; + int i = 0, size = 0; + + string_list = axis2_tokenize(env, style_default, ' '); + if(string_list) + size = AXIS2_ARRAY_LIST_SIZE(string_list, env); + for(i = 0; i < size; i++) + { + axis2_uri_t *uri = NULL; + uri_str = AXIS2_ARRAY_LIST_GET(string_list, env, i); + intface = woden_interface_to_interface_element(intface, env); + uri = get_uri(reader, env, uri_str); + WODEN_INTERFACE_ELEMENT_ADD_STYLE_DEFAULT_URI(intface, env, uri); + } + } + + /* TODO extends attribute */ + + intface = woden_interface_to_attr_extensible(intface, env); + status = parse_ext_attributes(reader, env, interface_el_node, "interface_element", + intface, desc); + if(AXIS2_SUCCESS != status) + return NULL; + + /* Parse the child elements of . + * As per WSDL 2.0 spec, they must be in the following order if present: + * + * or extension elements in any order + * TODO validate that the elements are in correct order + */ + temp_el = axiom_util_get_first_child_element(interface_el, env, interface_el_node, + &temp_el_node); + + while (NULL != temp_el && NULL != temp_el_node) + { + axis2_qname_t *q_elem_documentation = NULL; + axis2_qname_t *q_elem_fault = NULL; + axis2_qname_t *q_elem_op = NULL; + axis2_qname_t *q_elem_feature = NULL; + axis2_qname_t *q_elem_property = NULL; + + q_elem_documentation = axis2_qname_create_from_string(env, WODEN_Q_ELEM_DOCUMENTATION); + q_elem_fault = axis2_qname_create_from_string(env, WODEN_Q_ELEM_FAULT); + q_elem_op = axis2_qname_create_from_string(env, WODEN_Q_ELEM_OPERATION); + q_elem_feature = axis2_qname_create_from_string(env, WODEN_Q_ELEM_FEATURE); + q_elem_property = axis2_qname_create_from_string(env, WODEN_Q_ELEM_PROPERTY); + + if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_documentation, temp_el_node)) + { + void *documentation = NULL; + + documentation = parse_documentation(reader, env, temp_el_node, desc); + intface = woden_interface_to_documentable(intface, env); + WODEN_DOCUMENTABLE_ADD_DOCUMENTATION_ELEMENT(intface, env, documentation); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_fault, temp_el_node)) + { + void *intface_fault = NULL; + + intface_fault = parse_interface_fault(reader, env, temp_el_node, desc, + intface); + intface = woden_interface_to_interface_element(intface, env); + WODEN_INTERFACE_ELEMENT_ADD_INTERFACE_FAULT_ELEMENT(intface, env, intface_fault); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_op, temp_el_node)) + { + void *intface_op = NULL; + + intface_op = parse_interface_op(reader, env, temp_el_node, desc, + intface); + intface = woden_interface_to_interface_element(intface, env); + WODEN_INTERFACE_ELEMENT_ADD_INTERFACE_OP_ELEMENT(intface, env, intface_op); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_feature, temp_el_node)) + { + void *feature = NULL; + void *configurable = NULL; + + feature = parse_feature(reader, env, temp_el_node, desc, intface); + configurable = WODEN_INTERFACE_GET_BASE_IMPL(intface, env); + configurable = woden_configurable_to_configurable_element(configurable, env); + WODEN_CONFIGURABLE_ELEMENT_ADD_FEATURE_ELEMENT(configurable, env, feature); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_property, temp_el_node)) + { + void *property = NULL; + void *configurable = NULL; + + property = parse_property(reader, env, temp_el_node, desc, intface); + configurable = WODEN_INTERFACE_GET_BASE_IMPL(intface, env); + configurable = woden_configurable_to_configurable_element(configurable, env); + WODEN_CONFIGURABLE_ELEMENT_ADD_PROPERTY_ELEMENT(configurable, env, property); + } + else + { + void *ext_element = NULL; + + ext_element = parse_ext_element(reader, env, "interface_element", + intface, temp_el_node, desc); + intface = woden_interface_to_element_extensible(intface, env); + WODEN_ELEMENT_EXTENSIBLE_ADD_EXT_ELEMENT(intface, env, ext_element); + } + + temp_el = axiom_util_get_next_sibling_element(temp_el, env, + temp_el_node, &temp_el_node); + } + + return intface; +} + +/* Parse the attributes and child elements of interface . + * As per WSDL 2.0 spec, the child elements must be in the following order if present: + * + * or extension elements in any order + * + * TODO validate that the elements are in correct order + */ +static void * +parse_interface_fault( + void *reader, + const axis2_env_t *env, + axiom_node_t *fault_el_node, + void *desc, + void *parent) +{ + void *fault = NULL; + axis2_char_t *name = NULL; + axis2_char_t *element = NULL; + axiom_element_t *fault_el = NULL; + axiom_element_t *temp_el = NULL; + axiom_node_t *temp_el_node = NULL; + void *types = NULL; + void *nested_configurable = NULL; + axis2_status_t status = AXIS2_FAILURE; + + desc = woden_desc_to_desc_element(desc, env); + fault = WODEN_DESC_ELEMENT_CREATE_INTERFACE_FAULT_ELEMENT(desc, env); + nested_configurable = WODEN_INTERFACE_FAULT_GET_BASE_IMPL(fault, env); + nested_configurable = woden_nested_configurable_to_nested_element(nested_configurable, env); + WODEN_NESTED_ELEMENT_SET_PARENT_ELEMENT(nested_configurable, env, parent); + types = WODEN_DESC_ELEMENT_GET_TYPES_ELEMENT(desc, env); + WODEN_INTERFACE_FAULT_SET_TYPES(fault, env, types); + + fault_el = AXIOM_NODE_GET_DATA_ELEMENT(fault_el_node, env); + name = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(fault_el, env, WODEN_ATTR_NAME); + + if(NULL != name) + { + axis2_qname_t *qname = NULL; + axis2_uri_t *ns = NULL; + axis2_char_t *ns_str = NULL; + + ns = WODEN_DESC_ELEMENT_GET_TARGET_NAMESPACE(desc, env); + if(!ns) + ns_str = WODEN_VALUE_EMPTY_STRING; + ns_str = AXIS2_URI_TO_STRING(ns, env, AXIS2_URI_UNP_OMITUSERINFO); + qname = axis2_qname_create(env, name, ns_str, NULL); + fault = woden_interface_fault_to_interface_fault_element(fault, env); + WODEN_INTERFACE_FAULT_ELEMENT_SET_QNAME(fault, env, qname); + } + + element = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(fault_el, env, WODEN_ATTR_ELEMENT); + + if(NULL != element) + { + axis2_qname_t *qname = NULL; + axis2_hash_t *namespcs = NULL; + + desc = woden_desc_to_desc_element(desc, env); + namespcs = WODEN_DESC_ELEMENT_GET_NAMESPACES(desc, env); + + qname = woden_om_util_get_qname(env, fault_el_node, element, namespcs); + fault = woden_interface_fault_to_interface_fault_element(fault, env); + WODEN_INTERFACE_FAULT_ELEMENT_SET_QNAME(fault, env, qname); + } + + /* TODO extends attribute */ + + fault = woden_interface_fault_to_attr_extensible(fault, env); + status = parse_ext_attributes(reader, env, fault_el_node, "interface_fault_element", + fault, desc); + if(AXIS2_SUCCESS != status) + return NULL; + + temp_el = axiom_util_get_first_child_element(fault_el, env, fault_el_node, + &temp_el_node); + + while (NULL != temp_el && NULL != temp_el_node) + { + axis2_qname_t *q_elem_documentation = NULL; + axis2_qname_t *q_elem_feature = NULL; + axis2_qname_t *q_elem_property = NULL; + + q_elem_documentation = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_DOCUMENTATION); + q_elem_feature = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_FEATURE); + q_elem_property = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_PROPERTY); + + if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_documentation, temp_el_node)) + { + void *documentation = NULL; + + documentation = parse_documentation(reader, env, temp_el_node, desc); + fault = woden_interface_fault_to_documentable(fault, env); + WODEN_DOCUMENTABLE_ADD_DOCUMENTATION_ELEMENT(fault, env, documentation); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_feature, temp_el_node)) + { + void *feature = NULL; + + feature = parse_feature(reader, env, temp_el_node, desc, fault); + fault = woden_interface_fault_to_configurable_element(fault, env); + WODEN_CONFIGURABLE_ELEMENT_ADD_FEATURE_ELEMENT(fault, env, feature); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_property, temp_el_node)) + { + void *property = NULL; + + property = parse_property(reader, env, temp_el_node, desc, fault); + fault = woden_interface_fault_to_configurable_element(fault, env); + WODEN_CONFIGURABLE_ELEMENT_ADD_PROPERTY_ELEMENT(fault, env, property); + } + else + { + void *ext_element = NULL; + + ext_element = parse_ext_element(reader, env, "interface_fault_element", + fault, temp_el_node, desc); + fault = woden_interface_fault_to_element_extensible(fault, env); + WODEN_ELEMENT_EXTENSIBLE_ADD_EXT_ELEMENT(fault, env, ext_element); + } + + temp_el = axiom_util_get_next_sibling_element(temp_el, env, + temp_el_node, &temp_el_node); + } + + return fault; +} + +static void * +parse_interface_op( + void *reader, + const axis2_env_t *env, + axiom_node_t *op_el_node, + void *desc, + void *parent) +{ + void *op = NULL; + axis2_char_t *name = NULL; + axis2_char_t *style = NULL; + axis2_char_t *pat = NULL; + axiom_element_t *op_el = NULL; + axiom_element_t *temp_el = NULL; + axiom_node_t *temp_el_node = NULL; + void *nested_configurable = NULL; + axis2_status_t status = AXIS2_FAILURE; + + desc = woden_desc_to_desc_element(desc, env); + op = WODEN_DESC_ELEMENT_CREATE_INTERFACE_OP_ELEMENT(desc, env); + nested_configurable = WODEN_INTERFACE_OP_GET_BASE_IMPL(op, env); + nested_configurable = woden_nested_configurable_to_nested_element( + nested_configurable, env); + WODEN_NESTED_ELEMENT_SET_PARENT_ELEMENT(nested_configurable, env, parent); + + op_el = AXIOM_NODE_GET_DATA_ELEMENT(op_el_node, env); + name = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(op_el, env, WODEN_ATTR_NAME); + + if(NULL != name) + { + axis2_qname_t *qname = NULL; + axis2_uri_t *ns = NULL; + axis2_char_t *ns_str = NULL; + + ns = WODEN_DESC_ELEMENT_GET_TARGET_NAMESPACE(desc, env); + ns_str = AXIS2_URI_TO_STRING(ns, env, AXIS2_URI_UNP_OMITUSERINFO); + qname = axis2_qname_create(env, name, ns_str, NULL); + op = woden_interface_op_to_interface_op_element(op, env); + WODEN_INTERFACE_OP_ELEMENT_SET_QNAME(op, env, qname); + } + + style = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(op_el, env, WODEN_ATTR_STYLE); + + if(NULL != style) + { + axis2_array_list_t *str_list = NULL; + axis2_char_t *uri_str = NULL; + axis2_uri_t *uri = NULL; + int i = 0, size = 0; + + size = AXIS2_ARRAY_LIST_SIZE(str_list, env); + axis2_tokenize(env, style, ' '); + for(i = 0; i < size; i++) + { + uri_str = AXIS2_ARRAY_LIST_GET(str_list, env, i); + uri = get_uri(reader, env, uri_str); + op = woden_interface_op_to_interface_op_element(op, env); + WODEN_INTERFACE_OP_ELEMENT_ADD_STYLE_URI(op, env, uri); + } + } + + pat = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(op_el, env, WODEN_ATTR_PATTERN); + + if(NULL != pat) + { + axis2_uri_t *uri = NULL; + + uri = get_uri(reader, env, pat); + op = woden_interface_op_to_interface_op_element(op, env); + WODEN_INTERFACE_OP_ELEMENT_SET_PATTERN(op, env, uri); + } + op = woden_interface_op_to_attr_extensible(op, env); + status = parse_ext_attributes(reader, env, op_el_node, "interface_op_element", + op, desc); + if(AXIS2_SUCCESS != status) + return NULL; + + /* Parse the child elements of interface . + * As per WSDL 2.0 spec, they must be in the following order if present: + * + * or extension elements in any order + * TODO validate that the elements are in correct order + */ + temp_el = axiom_util_get_first_child_element(op_el, env, op_el_node, + &temp_el_node); + + while (NULL != temp_el && NULL != temp_el_node) + { + axis2_qname_t *q_elem_documentation = NULL; + axis2_qname_t *q_elem_feature = NULL; + axis2_qname_t *q_elem_property = NULL; + axis2_qname_t *q_elem_input = NULL; + axis2_qname_t *q_elem_output = NULL; + axis2_qname_t *q_elem_infault = NULL; + axis2_qname_t *q_elem_outfault = NULL; + + q_elem_documentation = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_DOCUMENTATION); + q_elem_feature = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_FEATURE); + q_elem_property = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_PROPERTY); + q_elem_input = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_INPUT); + q_elem_output = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_OUTPUT); + q_elem_infault = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_INFAULT); + q_elem_outfault = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_OUTFAULT); + + if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_documentation, temp_el_node)) + { + void *documentation = NULL; + + documentation = parse_documentation(reader, env, temp_el_node, desc); + op = woden_interface_op_to_documentable(op, env); + WODEN_DOCUMENTABLE_ADD_DOCUMENTATION_ELEMENT(op, env, documentation); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_feature, temp_el_node)) + { + void *feature = NULL; + + feature = parse_feature(reader, env, temp_el_node, desc, op); + op = woden_interface_op_to_configurable_element(op, env); + WODEN_CONFIGURABLE_ELEMENT_ADD_FEATURE_ELEMENT(op, env, feature); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_property, temp_el_node)) + { + void *property = NULL; + + property = parse_property(reader, env, temp_el_node, desc, op); + op = woden_interface_op_to_configurable_element(op, env); + WODEN_CONFIGURABLE_ELEMENT_ADD_PROPERTY_ELEMENT(op, env, property); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_input, temp_el_node)) + { + void *input = NULL; + + input = parse_interface_msg_ref(reader, env, temp_el_node, desc, op); + op = woden_interface_op_to_interface_op_element(op, env); + WODEN_INTERFACE_OP_ELEMENT_ADD_INTERFACE_MSG_REF_ELEMENT(op, env, input); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_output, temp_el_node)) + { + void *output = NULL; + + output = parse_interface_msg_ref(reader, env, temp_el_node, desc, op); + op = woden_interface_op_to_interface_op_element(op, env); + WODEN_INTERFACE_OP_ELEMENT_ADD_INTERFACE_MSG_REF_ELEMENT(op, env, output); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_infault, temp_el_node)) + { + void *infault = NULL; + + infault = parse_interface_fault_ref(reader, env, temp_el_node, desc, op); + op = woden_interface_op_to_interface_op_element(op, env); + WODEN_INTERFACE_OP_ELEMENT_ADD_INTERFACE_FAULT_REF_ELEMENT(op, env, infault); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_outfault, temp_el_node)) + { + void *outfault = NULL; + + outfault = parse_interface_fault_ref(reader, env, temp_el_node, desc, op); + op = woden_interface_op_to_interface_op_element(op, env); + WODEN_INTERFACE_OP_ELEMENT_ADD_INTERFACE_FAULT_REF_ELEMENT(op, env, outfault); + } + else + { + void *ext_element = NULL; + + ext_element = parse_ext_element(reader, env, "interface_op_element", + op, temp_el_node, desc); + op = woden_interface_op_to_element_extensible(op, env); + WODEN_ELEMENT_EXTENSIBLE_ADD_EXT_ELEMENT(op, env, ext_element); + } + + temp_el = axiom_util_get_next_sibling_element(temp_el, env, + temp_el_node, &temp_el_node); + } + + return op; +} + +static void * +parse_interface_fault_ref( + void *reader, + const axis2_env_t *env, + axiom_node_t *fault_ref_el_node, + void *desc, + void *parent) +{ + void *fault_ref = NULL; + axis2_char_t *ref = NULL; + axis2_char_t *localname = NULL; + axis2_char_t *msg_label_str = NULL; + axiom_element_t *fault_ref_el = NULL; + axiom_element_t *temp_el = NULL; + axiom_node_t *temp_el_node = NULL; + axis2_qname_t *attr_ref = NULL; + void *nested_configurable = NULL; + axis2_status_t status = AXIS2_FAILURE; + + desc = woden_desc_to_desc_element(desc, env); + fault_ref = WODEN_DESC_ELEMENT_CREATE_INTERFACE_FAULT_REF_ELEMENT(desc, + env); + nested_configurable = WODEN_INTERFACE_FAULT_REF_GET_BASE_IMPL(fault_ref, env); + nested_configurable = woden_nested_configurable_to_nested_element( + nested_configurable, env); + WODEN_NESTED_ELEMENT_SET_PARENT_ELEMENT(nested_configurable, env, parent); + + fault_ref_el = AXIOM_NODE_GET_DATA_ELEMENT(fault_ref_el_node, env); + localname = AXIOM_ELEMENT_GET_LOCALNAME(fault_ref_el, env); + if(0 == AXIS2_STRCMP(WODEN_ELEM_INFAULT, localname)) + { + woden_direction_t *direction_in = NULL; + + direction_in = woden_direction_get_direction_in(env); + WODEN_INTERFACE_FAULT_REF_ELEMENT_SET_DIRECTION(fault_ref, env, direction_in); + } + if(0 == AXIS2_STRCMP(WODEN_ELEM_OUTFAULT, localname)) + { + woden_direction_t *direction_out = NULL; + + direction_out = woden_direction_get_direction_out(env); + fault_ref = woden_interface_fault_ref_to_interface_fault_ref_element( + fault_ref, env); + WODEN_INTERFACE_FAULT_REF_ELEMENT_SET_DIRECTION(fault_ref, env, direction_out); + } + + attr_ref = axis2_qname_create_from_string(env, WODEN_ATTR_REF); + ref = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(fault_ref_el, env, WODEN_ATTR_REF); + + if(NULL != ref) + { + axis2_qname_t *qname = NULL; + axis2_hash_t *namespcs = NULL; + + desc = woden_desc_to_desc_element(desc, env); + namespcs = WODEN_DESC_ELEMENT_GET_NAMESPACES(desc, env); + + qname = woden_om_util_get_qname(env, fault_ref_el_node, ref, namespcs); + fault_ref = + woden_interface_fault_ref_to_interface_fault_ref_element( + fault_ref, env); + WODEN_INTERFACE_FAULT_REF_ELEMENT_SET_REF(fault_ref, env, qname); + } + + msg_label_str = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(fault_ref_el, env, + WODEN_ATTR_MESSAGE_LABEL); + + if(NULL != msg_label_str) + { + woden_msg_label_t *msg_label_in = NULL; + woden_msg_label_t *msg_label_out = NULL; + axis2_char_t *label_in_str = NULL; + axis2_char_t *label_out_str = NULL; + + msg_label_in = woden_msg_label_get_msg_label_in(env); + label_in_str = WODEN_MSG_LABEL_TO_STRING(msg_label_in, env); + msg_label_out = woden_msg_label_get_msg_label_out(env); + label_out_str = WODEN_MSG_LABEL_TO_STRING(msg_label_out, env); + if(0 == AXIS2_STRCMP(msg_label_str, label_in_str)) + { + fault_ref = + woden_interface_fault_ref_to_interface_fault_ref_element( + fault_ref, env); + WODEN_INTERFACE_FAULT_REF_ELEMENT_SET_MSG_LABEL(fault_ref, + env, msg_label_in); + } + else if (0 == AXIS2_STRCMP(msg_label_str, label_out_str)) + { + fault_ref = + woden_interface_fault_ref_to_interface_fault_ref_element( + fault_ref, env); + WODEN_INTERFACE_FAULT_REF_ELEMENT_SET_MSG_LABEL(fault_ref, + env, msg_label_out); + } + else + { + woden_msg_label_t *msg_label_invalid = NULL; + + /* Invalid value, but capture it anyway. */ + msg_label_invalid = woden_msg_label_get_invalid_value(env, msg_label_str); + fault_ref = + woden_interface_fault_ref_to_interface_fault_ref_element( + fault_ref, env); + WODEN_INTERFACE_FAULT_REF_ELEMENT_SET_MSG_LABEL(fault_ref, + env, msg_label_invalid); + } + } + + fault_ref = woden_interface_fault_ref_to_attr_extensible(fault_ref, env); + status = parse_ext_attributes(reader, env, fault_ref_el_node, "interface_fault_ref_element", + fault_ref, desc); + if(AXIS2_SUCCESS != status) + return NULL; + + temp_el = axiom_util_get_first_child_element(fault_ref_el, env, fault_ref_el_node, + &temp_el_node); + + while (NULL != temp_el && NULL != temp_el_node) + { + axis2_qname_t *q_elem_documentation = NULL; + axis2_qname_t *q_elem_feature = NULL; + axis2_qname_t *q_elem_property = NULL; + + q_elem_documentation = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_DOCUMENTATION); + q_elem_feature = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_FEATURE); + q_elem_property = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_PROPERTY); + + if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_documentation, temp_el_node)) + { + void *documentation = NULL; + + documentation = parse_documentation(reader, env, temp_el_node, desc); + fault_ref = woden_interface_fault_ref_to_documentable(fault_ref, env); + WODEN_DOCUMENTABLE_ADD_DOCUMENTATION_ELEMENT(fault_ref, env, documentation); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_feature, temp_el_node)) + { + void *feature = NULL; + + feature = parse_feature(reader, env, temp_el_node, desc, fault_ref); + fault_ref = woden_interface_fault_ref_to_configurable_element(fault_ref, env); + WODEN_CONFIGURABLE_ELEMENT_ADD_FEATURE_ELEMENT(fault_ref, env, feature); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_property, temp_el_node)) + { + void *property = NULL; + + property = parse_property(reader, env, temp_el_node, desc, fault_ref); + fault_ref = woden_interface_fault_ref_to_configurable_element(fault_ref, env); + WODEN_CONFIGURABLE_ELEMENT_ADD_PROPERTY_ELEMENT(fault_ref, env, property); + } + else + { + void *ext_element = NULL; + + ext_element = parse_ext_element(reader, env, "interface_fault_ref_element", + fault_ref, temp_el_node, desc); + fault_ref = woden_interface_fault_ref_to_element_extensible(fault_ref, env); + WODEN_ELEMENT_EXTENSIBLE_ADD_EXT_ELEMENT(fault_ref, env, ext_element); + } + + temp_el = axiom_util_get_next_sibling_element(temp_el, env, + temp_el_node, &temp_el_node); + } + + return fault_ref; +} + +static void * +parse_interface_msg_ref( + void *reader, + const axis2_env_t *env, + axiom_node_t *msg_ref_el_node, + void *desc, + void *parent) +{ + void *msg_ref = NULL; + axis2_char_t *element = NULL; + axis2_char_t *localname = NULL; + axis2_char_t *msg_label_str = NULL; + axiom_element_t *msg_ref_el; + axiom_element_t *temp_el; + axiom_node_t *temp_el_node; + void *types = NULL; + void *nested_configurable = NULL; + axis2_status_t status = AXIS2_FAILURE; + + desc = woden_desc_to_desc_element(desc, env); + msg_ref = WODEN_DESC_ELEMENT_CREATE_INTERFACE_MSG_REF_ELEMENT(desc, + env); + nested_configurable = WODEN_INTERFACE_MSG_REF_GET_BASE_IMPL(msg_ref, env); + nested_configurable = woden_nested_configurable_to_nested_element( + nested_configurable, env); + WODEN_NESTED_ELEMENT_SET_PARENT_ELEMENT(nested_configurable, env, parent); + desc = woden_desc_to_desc_element(desc, env); + types = WODEN_DESC_ELEMENT_GET_TYPES_ELEMENT(desc, env); + WODEN_INTERFACE_MSG_REF_SET_TYPES(msg_ref, env, types); + + msg_ref_el = AXIOM_NODE_GET_DATA_ELEMENT(msg_ref_el_node, env); + localname = AXIOM_ELEMENT_GET_LOCALNAME(msg_ref_el, env); + if(0 == AXIS2_STRCMP(WODEN_ELEM_INPUT, localname)) + { + woden_direction_t *direction_in = NULL; + + direction_in = woden_direction_get_direction_in(env); + msg_ref = woden_interface_msg_ref_to_interface_msg_ref_element( + msg_ref, env); + WODEN_INTERFACE_MSG_REF_ELEMENT_SET_DIRECTION(msg_ref, env, direction_in); + } + if(0 == AXIS2_STRCMP(WODEN_ELEM_OUTPUT, localname)) + { + woden_direction_t *direction_out = NULL; + + direction_out = woden_direction_get_direction_out(env); + msg_ref = woden_interface_msg_ref_to_interface_msg_ref_element( + msg_ref, env); + WODEN_INTERFACE_MSG_REF_ELEMENT_SET_DIRECTION(msg_ref, env, direction_out); + } + + msg_label_str = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(msg_ref_el, env, + WODEN_ATTR_MESSAGE_LABEL); + + if(NULL != msg_label_str) + { + woden_msg_label_t *msg_label_in = NULL; + woden_msg_label_t *msg_label_out = NULL; + axis2_char_t *label_in_str = NULL; + axis2_char_t *label_out_str = NULL; + + msg_label_in = woden_msg_label_get_msg_label_in(env); + label_in_str = WODEN_MSG_LABEL_TO_STRING(msg_label_in, env); + msg_label_out = woden_msg_label_get_msg_label_out(env); + label_out_str = WODEN_MSG_LABEL_TO_STRING(msg_label_out, env); + if(0 == AXIS2_STRCMP(msg_label_str, label_in_str)) + { + msg_ref = + woden_interface_msg_ref_to_interface_msg_ref_element( + msg_ref, env); + WODEN_INTERFACE_MSG_REF_ELEMENT_SET_MSG_LABEL(msg_ref, + env, msg_label_in); + } + else if (0 == AXIS2_STRCMP(msg_label_str, label_out_str)) + { + msg_ref = + woden_interface_msg_ref_to_interface_msg_ref_element( + msg_ref, env); + WODEN_INTERFACE_MSG_REF_ELEMENT_SET_MSG_LABEL(msg_ref, + env, msg_label_out); + } + else + { + woden_msg_label_t *msg_label_invalid = NULL; + + /* Invalid value, but capture it anyway. */ + msg_label_invalid = woden_msg_label_get_invalid_value(env, msg_label_str); + msg_ref = + woden_interface_msg_ref_to_interface_msg_ref_element( + msg_ref, env); + WODEN_INTERFACE_MSG_REF_ELEMENT_SET_MSG_LABEL(msg_ref, + env, msg_label_invalid); + } + } + else + { + woden_direction_t *direction = NULL; + woden_direction_t *direction_in = NULL; + woden_direction_t *direction_out = NULL; + woden_msg_label_t *msg_label_in = NULL; + woden_msg_label_t *msg_label_out = NULL; + + msg_label_in = woden_msg_label_get_msg_label_in(env); + msg_label_out = woden_msg_label_get_msg_label_out(env); + direction = WODEN_INTERFACE_MSG_REF_GET_DIRECTION(msg_ref, env); + direction_in = woden_direction_get_direction_in(env); + direction_out = woden_direction_get_direction_out(env); + /* This is a temp fix, correct action is to use MEP to determine default + */ + if(direction == direction_in) + { + msg_ref = + woden_interface_msg_ref_to_interface_msg_ref_element( + msg_ref, env); + WODEN_INTERFACE_MSG_REF_ELEMENT_SET_MSG_LABEL(msg_ref, + env, msg_label_in); + } + else + { + msg_ref = + woden_interface_msg_ref_to_interface_msg_ref_element( + msg_ref, env); + WODEN_INTERFACE_MSG_REF_ELEMENT_SET_MSG_LABEL(msg_ref, + env, msg_label_out); + } + } + + element = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(msg_ref_el, env, WODEN_ATTR_ELEMENT); + + if(NULL != element) + { + if(0 == AXIS2_STRCMP(element, WODEN_NMTOKEN_ANY) || + 0 == AXIS2_STRCMP(element, WODEN_NMTOKEN_NONE) || + 0 == AXIS2_STRCMP(element, WODEN_NMTOKEN_OTHER)) + { + msg_ref = + woden_interface_msg_ref_to_interface_msg_ref_element( + msg_ref, env); + WODEN_INTERFACE_MSG_REF_ELEMENT_SET_MSG_CONTENT_MODEL(msg_ref, + env, element); + } + else + { + axis2_qname_t *qname = NULL; + axis2_hash_t *namespcs = NULL; + + /* element is not #any, #none or #other, so it must be an element + * qname + */ + msg_ref = + woden_interface_msg_ref_to_interface_msg_ref_element( + msg_ref, env); + WODEN_INTERFACE_MSG_REF_ELEMENT_SET_MSG_CONTENT_MODEL(msg_ref, + env, element); + + desc = woden_desc_to_desc_element(desc, env); + namespcs = WODEN_DESC_ELEMENT_GET_NAMESPACES(desc, env); + qname = woden_om_util_get_qname(env, msg_ref_el_node, element, namespcs); + WODEN_INTERFACE_MSG_REF_ELEMENT_SET_ELEMENT_QNAME(msg_ref, + env, qname); + } + } + else + { + /* Per mapping defined in WSDL2.0 Part2 spec section 2.5.3, + * if element attribute not present, message content model is #other + */ + msg_ref = + woden_interface_msg_ref_to_interface_msg_ref_element( + msg_ref, env); + WODEN_INTERFACE_MSG_REF_ELEMENT_SET_MSG_CONTENT_MODEL(msg_ref, env, + WODEN_NMTOKEN_OTHER); + + } + + msg_ref = woden_interface_msg_ref_to_attr_extensible(msg_ref, env); + status = parse_ext_attributes(reader, env, msg_ref_el_node, "interface_msg_ref_element", + msg_ref, desc); + if(AXIS2_SUCCESS != status) + return NULL; + + temp_el = axiom_util_get_first_child_element(msg_ref_el, env, msg_ref_el_node, + &temp_el_node); + + while (NULL != temp_el && NULL != temp_el_node) + { + axis2_qname_t *q_elem_documentation = NULL; + axis2_qname_t *q_elem_feature = NULL; + axis2_qname_t *q_elem_property = NULL; + + q_elem_documentation = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_DOCUMENTATION); + q_elem_feature = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_FEATURE); + q_elem_property = axis2_qname_create_from_string(env, + WODEN_Q_ELEM_PROPERTY); + + if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_documentation, temp_el_node)) + { + void *documentation = NULL; + + documentation = parse_documentation(reader, env, temp_el_node, desc); + msg_ref = woden_interface_msg_ref_to_documentable(msg_ref, env); + WODEN_DOCUMENTABLE_ADD_DOCUMENTATION_ELEMENT(msg_ref, env, documentation); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_feature, temp_el_node)) + { + void *feature = NULL; + + feature = parse_feature(reader, env, temp_el_node, desc, msg_ref); + msg_ref = woden_interface_msg_ref_to_configurable_element(msg_ref, env); + WODEN_CONFIGURABLE_ELEMENT_ADD_FEATURE_ELEMENT(msg_ref, env, feature); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_property, temp_el_node)) + { + void *property = NULL; + + property = parse_property(reader, env, temp_el_node, desc, msg_ref); + msg_ref = woden_interface_msg_ref_to_configurable_element(msg_ref, env); + WODEN_CONFIGURABLE_ELEMENT_ADD_PROPERTY_ELEMENT(msg_ref, env, property); + } + else + { + void *ext_element = NULL; + + ext_element = parse_ext_element(reader, env, "interface_msg_ref_element", + msg_ref, temp_el_node, desc); + msg_ref = woden_interface_msg_ref_to_element_extensible(msg_ref, env); + WODEN_ELEMENT_EXTENSIBLE_ADD_EXT_ELEMENT(msg_ref, env, ext_element); + } + + temp_el = axiom_util_get_next_sibling_element(temp_el, env, + temp_el_node, &temp_el_node); + } + + return msg_ref; +} + +static void * +parse_binding( + void *reader, + const axis2_env_t *env, + axiom_node_t *binding_el_node, + void *desc) +{ + void *binding = NULL; + axis2_char_t *name = NULL; + axis2_char_t *type = NULL; + axis2_char_t *intface = NULL; + axiom_element_t *binding_el; + axiom_element_t *temp_el; + axiom_node_t *temp_el_node; + axis2_qname_t *intface_qn = NULL; + void *configurable = NULL; + void *documentable = NULL; + void *wsdl_obj = NULL; + axis2_status_t status = AXIS2_FAILURE; + + desc = woden_desc_to_desc_element(desc, env); + binding = WODEN_DESC_ELEMENT_CREATE_BINDING_ELEMENT(desc, env); + + binding_el = AXIOM_NODE_GET_DATA_ELEMENT(binding_el_node, env); + name = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(binding_el, env, WODEN_ATTR_NAME); + + if(NULL != name) + { + axis2_qname_t *qname = NULL; + axis2_uri_t *namespc = NULL; + axis2_char_t *namespc_str = NULL; + + namespc = WODEN_DESC_ELEMENT_GET_TARGET_NAMESPACE(desc, env); + namespc_str = AXIS2_URI_TO_STRING(namespc, env, AXIS2_URI_UNP_OMITUSERINFO); + qname = axis2_qname_create(env, name, namespc_str, NULL); + binding = woden_binding_to_binding_element(binding, env); + WODEN_BINDING_ELEMENT_SET_QNAME(binding, env, qname); + } + + intface = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(binding_el, env, WODEN_ATTR_INTERFACE); + if(NULL != intface) + { + axis2_hash_t *namespcs = NULL; + + desc = woden_desc_to_desc_element(desc, env); + namespcs = WODEN_DESC_ELEMENT_GET_NAMESPACES(desc, env); + intface_qn = woden_om_util_get_qname(env, binding_el_node, intface, namespcs); + binding = woden_binding_to_binding_element(binding, env); + WODEN_BINDING_ELEMENT_SET_INTERFACE_QNAME(binding, env, intface_qn); + } + /* Dereference the interface qname */ + if(NULL != intface_qn) + { + axis2_array_list_t *interfaces = NULL; + int i = 0, size = 0; + + desc = woden_desc_to_desc_element(desc, env); + interfaces = WODEN_DESC_ELEMENT_GET_INTERFACE_ELEMENTS(desc, env); + size = AXIS2_ARRAY_LIST_SIZE(interfaces, env); + for(i = 0; i < size; i++) + { + void *intface = NULL; + axis2_qname_t *qname = NULL; + + intface = AXIS2_ARRAY_LIST_GET(interfaces, env, i); + intface = woden_interface_to_interface_element(intface, env); + qname = WODEN_INTERFACE_ELEMENT_GET_QNAME(intface, env); + if(AXIS2_TRUE == AXIS2_QNAME_EQUALS(intface_qn, env, qname)) + { + WODEN_BINDING_SET_INTERFACE_ELEMENT(binding, env, intface); + } + } + } + + type = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(binding_el, env, WODEN_ATTR_TYPE); + + if(NULL != type) + { + axis2_uri_t *uri = NULL; + + uri = get_uri(reader, env, type); + binding = woden_binding_to_binding_element(binding, env); + WODEN_BINDING_ELEMENT_SET_TYPE(binding, env, uri); + } + + /* TODO extends attribute */ + + configurable = WODEN_BINDING_GET_BASE_IMPL(binding, env); + documentable = WODEN_CONFIGURABLE_GET_BASE_IMPL(configurable, env); + wsdl_obj = WODEN_DOCUMENTABLE_GET_BASE_IMPL(documentable, env); + + status = parse_ext_attributes(reader, env, binding_el_node, "binding_element", + binding, desc); + if(AXIS2_SUCCESS != status) + return NULL; + + /* Parse the child elements of . + * As per WSDL 2.0 spec, they must be in the following order if present: + * + * or extension elements in any order + * TODO validate that the elements are in correct order + */ + temp_el = axiom_util_get_first_child_element(binding_el, env, binding_el_node, + &temp_el_node); + + while (NULL != temp_el && NULL != temp_el_node) + { + axis2_qname_t *q_elem_documentation = NULL; + axis2_qname_t *q_elem_fault = NULL; + axis2_qname_t *q_elem_op = NULL; + axis2_qname_t *q_elem_feature = NULL; + axis2_qname_t *q_elem_property = NULL; + + q_elem_documentation = axis2_qname_create_from_string(env, WODEN_Q_ELEM_DOCUMENTATION); + q_elem_fault = axis2_qname_create_from_string(env, WODEN_Q_ELEM_FAULT); + q_elem_op = axis2_qname_create_from_string(env, WODEN_Q_ELEM_OPERATION); + q_elem_feature = axis2_qname_create_from_string(env, WODEN_Q_ELEM_FEATURE); + q_elem_property = axis2_qname_create_from_string(env, WODEN_Q_ELEM_PROPERTY); + + if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_documentation, temp_el_node)) + { + void *documentation = NULL; + + documentation = parse_documentation(reader, env, temp_el_node, desc); + binding = woden_binding_to_documentable(binding, env); + WODEN_DOCUMENTABLE_ADD_DOCUMENTATION_ELEMENT(binding, env, documentation); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_fault, temp_el_node)) + { + void *binding_fault = NULL; + binding_fault = parse_binding_fault(reader, env, temp_el_node, desc, + binding); + binding = woden_binding_to_binding_element(binding, env); + WODEN_BINDING_ELEMENT_ADD_BINDING_FAULT_ELEMENT(binding, env, binding_fault); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_op, temp_el_node)) + { + void *binding_op = NULL; + + binding_op = parse_binding_op(reader, env, temp_el_node, desc, + binding); + binding = woden_binding_to_binding_element(binding, env); + WODEN_BINDING_ELEMENT_ADD_BINDING_OP_ELEMENT(binding, env, binding_op); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_feature, temp_el_node)) + { + void *feature = NULL; + + feature = parse_feature(reader, env, temp_el_node, desc, binding); + binding = woden_binding_to_configurable_element(binding, env); + WODEN_CONFIGURABLE_ELEMENT_ADD_FEATURE_ELEMENT(binding, env, feature); + } + else if(AXIS2_TRUE == axis2_qname_util_matches(env, + q_elem_property, temp_el_node)) + { + void *property = NULL; + + property = parse_property(reader, env, temp_el_node, desc, binding); + binding = woden_binding_to_configurable_element(binding, env); + WODEN_CONFIGURABLE_ELEMENT_ADD_PROPERTY_ELEMENT(binding, env, property); + } + else + { + void *ext_element = NULL; + void *configurable = NULL; + void *documentable = NULL; + void *wsdl_obj = NULL; + void *wsdl_el = NULL; + + ext_element = parse_ext_element(reader, env, "binding_element", + binding, temp_el_node, desc); + configurable = WODEN_BINDING_GET_BASE_IMPL(binding, env); + documentable = WODEN_CONFIGURABLE_GET_BASE_IMPL(configurable, env); + wsdl_obj = WODEN_DOCUMENTABLE_GET_BASE_IMPL(documentable, env); + wsdl_el = WODEN_WSDL_OBJ_GET_BASE_IMPL(wsdl_obj, env); + + wsdl_el = woden_wsdl_element_to_element_extensible(wsdl_el, env); + WODEN_ELEMENT_EXTENSIBLE_ADD_EXT_ELEMENT(wsdl_el, env, ext_element); + } + + temp_el = axiom_util_get_next_sibling_element(temp_el, env, + temp_el_node, &temp_el_node); + } + + return binding; +} + +static void * +parse_binding_fault( + void *reader, + const axis2_env_t *env, + axiom_node_t *fault_el_node, + void *desc, + void *parent) +{ + void *fault = NULL; + axis2_char_t *ref = NULL; + axiom_element_t *fault_el; + axiom_element_t *temp_el; + axiom_node_t *temp_el_node; + axis2_qname_t *attr_ref = NULL; + axis2_qname_t *int_flt_qn = NULL; + void *nested_configurable = NULL; + axis2_status_t status = AXIS2_FAILURE; + + desc = woden_desc_to_desc_element(desc, env); + fault = WODEN_DESC_ELEMENT_CREATE_BINDING_FAULT_ELEMENT(desc, env); + nested_configurable = WODEN_BINDING_FAULT_GET_BASE_IMPL(fault, env); + nested_configurable = woden_nested_configurable_to_nested_element( + nested_configurable, env); + WODEN_NESTED_ELEMENT_SET_PARENT_ELEMENT(nested_configurable, env, parent); + + attr_ref = axis2_qname_create_from_string(env, WODEN_ATTR_NAME); + fault_el = AXIOM_NODE_GET_DATA_ELEMENT(fault_el_node, env); [... 1612 lines stripped ...] --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org