AXIS2_EXTERN axutil_param_t *AXIS2_CALL axutil_param_create( const axutil_env_t *env, axis2_char_t *name, void *value) { axutil_param_t *param = NULL; AXIS2_ENV_CHECK(env, NULL); param = AXIS2_MALLOC(env->allocator, sizeof(axutil_param_t)); if(!param) { AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Not enough memory"); AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE); return NULL; } param->name = axutil_strdup(env, name); param->value = value; /* shallow copy. */ param->locked = AXIS2_FALSE; param->type = AXIS2_TEXT_PARAM; param->attrs = NULL; param->value_list = NULL; param->value_free = NULL; return param; }
AXIS2_EXTERN axis2_handler_t *AXIS2_CALL axis2_handler_create( const axutil_env_t * env) { axis2_handler_t *handler = NULL; handler = AXIS2_MALLOC(env->allocator, sizeof(axis2_handler_t)); if(!handler) { AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY); AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE); return NULL; } handler->handler_desc = NULL; return handler; }
AXIS2_EXTERN axis2_bool_t AXIS2_CALL axutil_qname_equals( const axutil_qname_t *qname, const axutil_env_t *env, const axutil_qname_t *qname2) { int uris_differ = 0; int localparts_differ = 0; AXIS2_ENV_CHECK(env, AXIS2_FALSE); if(!qname2) { AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_INVALID_NULL_PARAM); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL parameter was passed when a non NULL parameter was expected"); AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE); return AXIS2_FALSE; } if(qname->localpart && qname2->localpart) { localparts_differ = axutil_strcmp(qname->localpart, qname2->localpart); } else { localparts_differ = ((qname->localpart) || (qname2->localpart)); } if(qname->namespace_uri && qname2->namespace_uri) { uris_differ = axutil_strcmp(qname->namespace_uri, qname2->namespace_uri); } else { uris_differ = ((qname->namespace_uri) || (qname2->namespace_uri)); } return (!uris_differ && !localparts_differ) ? AXIS2_TRUE : AXIS2_FALSE; }
/* * This method invokes the target service method */ static axiom_node_t* AXIS2_CALL Axis2Service_invoke(axis2_svc_skeleton_t* /*pServiceSkeleton*/, const axutil_env_t* pEnv, axiom_node_t* pAxiomNode, axis2_msg_ctx_t* pMsgCtx) { if (pAxiomNode == NULL) { staff::LogError() << "AxiOM node is NULL\n"; return NULL; } if (axiom_node_get_node_type(pAxiomNode, pEnv) != AXIOM_ELEMENT) { staff::LogError() << "Can't get AxiOM node type"; return NULL; } axiom_element_t* pAxiomElement = (axiom_element_t*)axiom_node_get_data_element(pAxiomNode, pEnv); if (pAxiomElement == NULL) { staff::LogError() << "Can't get AxiOM node element\n"; return NULL; } const axis2_char_t* szServiceName = reinterpret_cast<const axis2_char_t*> (axis2_msg_ctx_get_property_value(pMsgCtx, pEnv, "ServiceName")); #ifndef WITHOUT_SECURITY const axis2_char_t* szSessionId = reinterpret_cast<const axis2_char_t*> (axis2_msg_ctx_get_property_value(pMsgCtx, pEnv, "SessionId")); const axis2_char_t* szInstanceId = reinterpret_cast<const axis2_char_t*> (axis2_msg_ctx_get_property_value(pMsgCtx, pEnv, "InstanceId")); #endif if (szServiceName == NULL) { staff::LogError() << "Cannot process message: Failed to get service name."; return NULL; } #ifndef WITHOUT_SECURITY if (szSessionId == NULL) { staff::LogError() << "Cannot process message: Failed to get session id."; return NULL; } if (szInstanceId == NULL) { staff::LogError() << "Cannot process message: Failed to get instance id."; return NULL; } #endif #ifdef _DEBUG staff::LogDebug1() << "Service name: [" << szServiceName << "]"; #ifndef WITHOUT_SECURITY staff::LogDebug1() << "Session id: [" << szSessionId << "]"; staff::LogDebug1() << "Instance id: [" << szInstanceId << "]"; #endif { axiom_node_t* panBody = axiom_node_get_parent(pAxiomNode, pEnv); axiom_node_t* panEnv = axiom_node_get_parent(panBody, pEnv); staff::LogDebug2() << "request SOAP Envelope: \n" << staff::ColorTextBlue << staff::DataObject(panEnv).ToString() << "\n" << staff::ColorDefault; } #endif staff::Operation tOperation; staff::MessageContext tMessageContext(pEnv, pMsgCtx); std::string sServiceName(szServiceName); #ifndef WITHOUT_SECURITY std::string sSessionId(szSessionId); std::string sInstanceId(szInstanceId); #else static std::string sSessionId; static std::string sInstanceId; #endif try { tOperation.SetRequest(pAxiomNode); tOperation.SetMessageContext(tMessageContext); if (axis2_msg_ctx_get_doing_rest(pMsgCtx, pEnv)) { const axis2_char_t* szOperation = reinterpret_cast<const axis2_char_t*> (axis2_msg_ctx_get_property_value(pMsgCtx, pEnv, "Operation")); if (szOperation != NULL) { tOperation.SetName(szOperation); } } if (sServiceName == "StaffService") { staff::ServiceDispatcher::Inst().InvokeSelf(tOperation); } else { staff::ServiceWrapper* pServiceWrapper = staff::SharedContext::Inst().GetService(sServiceName); STAFF_ASSERT(pServiceWrapper, "Service [" + sServiceName + "] is not found: "); pServiceWrapper->Invoke(tOperation, sSessionId, sInstanceId); } } catch (const staff::SoapUserFaultException& rEx) { try { staff::DataObject tdoFault; tdoFault.FromString(rEx.GetFault()); tOperation.SetUserFault(tdoFault); } catch (...) { tOperation.SetFault("server", "Invalid format of user soap fault", "Failed to invoke service " + sServiceName + "." + tOperation.GetName() #ifndef WITHOUT_SECURITY + "#" + sInstanceId + "(" + sSessionId + ")" #endif ); } } catch (const staff::SoapFaultException& rEx) { tOperation.SetFault(rEx.GetCode(), rEx.GetString(), rEx.GetDetail()); } catch (const std::exception& rEx) { tOperation.SetFault("server", rEx.what(), "Failed to invoke service " + sServiceName + "." + tOperation.GetName() #ifndef WITHOUT_SECURITY + "#" + sInstanceId + "(" + sSessionId + ")" #endif ); } catch (...) { tOperation.SetFault("server", "Unknown exception", "Failed to invoke service " + sServiceName + "." + tOperation.GetName() #ifndef WITHOUT_SECURITY + "#" + sInstanceId + "(" + sSessionId + ")" #endif ); } if (tOperation.IsFault()) { staff::ScopedLock tLock(m_tFaultDetailsMutex); m_mFaultDetails[staff::Thread::GetCurrentId()] = tOperation.GetFaultDetail(); staff::LogWarning() << "Fault: \n" << tOperation.GetFaultDescr() << "\n"; AXIS2_ERROR_SET_MESSAGE(pEnv->error, static_cast<axis2_char_t*>(axutil_strdup(pEnv, tOperation.GetFaultString().c_str()))); AXIS2_ERROR_SET_ERROR_NUMBER(pEnv->error, static_cast<axutil_error_codes_t>(AXUTIL_ERROR_MAX + 1)); AXIS2_ERROR_SET_STATUS_CODE(pEnv->error, AXIS2_FAILURE); if (!m_bHttp200OnFault) return NULL; } if(!IsNeedReply(pMsgCtx, pEnv)) { return NULL; } tOperation.PrepareResult(); staff::DataObject& rResponse = tOperation.GetResponse(); rResponse.SetOwner(false); #ifdef _DEBUG staff::LogDebug2() << "Sending Response: \n" << staff::ColorTextBlue << rResponse.ToString() << "\n" << staff::ColorDefault; #endif return rResponse; }
AXIS2_EXTERN axutil_qname_t *AXIS2_CALL axutil_qname_create( const axutil_env_t *env, const axis2_char_t *localpart, const axis2_char_t *namespace_uri, const axis2_char_t *prefix) { axutil_qname_t *qname = NULL; AXIS2_ENV_CHECK(env, NULL); /* localpart can't be null */ if(!localpart) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL parameter was passed when a non NULL parameter was expected"); return NULL; } qname = (axutil_qname_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_qname_t)); if(!qname) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory"); return NULL; } /* set properties */ qname->localpart = NULL; qname->qname_string = NULL; qname->prefix = NULL; qname->namespace_uri = NULL; qname->ref = 1; qname->localpart = (axis2_char_t *)axutil_strdup(env, localpart); if(!(qname->localpart)) { AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory"); AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE); axutil_qname_free(qname, env); return NULL; } if(prefix) { qname->prefix = (axis2_char_t *)axutil_strdup(env, prefix); } if(prefix && !(qname->prefix)) { AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory"); AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE); axutil_qname_free(qname, env); return NULL; } if(namespace_uri) { qname->namespace_uri = (axis2_char_t *)axutil_strdup(env, namespace_uri); } if(namespace_uri && !(qname->namespace_uri)) { AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory"); AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE); axutil_qname_free(qname, env); return NULL; } return qname; }