org.apache.axis2.context.MessageContext Java Examples

The following examples show how to use org.apache.axis2.context.MessageContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SubmitObjectsRequest.java    From openxds with Apache License 2.0 6 votes vote down vote up
/**
 * Audit Logging of Register Document Set message.
 */
private void auditLog(String patientId, String submissionSetUid, AuditCodeMappings.AuditTypeCodes typeCode) {
	if (auditLog == null)
		return;
	String replyto = getMessageContext().getReplyTo().getAddress();
	String remoteIP = (String)getMessageContext().getProperty(MessageContext.REMOTE_ADDR);
	String localIP = (String)getMessageContext().getProperty(MessageContext.TRANSPORT_ADDR);
	
	ParticipantObject set = new ParticipantObject("SubmissionSet", submissionSetUid);
	ParticipantObject patientObj = new ParticipantObject("PatientIdentifier", patientId);
	
	ActiveParticipant source = new ActiveParticipant();
	source.setUserId(replyto);
	source.setAccessPointId(remoteIP);
	//TODO: Needs to be improved
	String userid = "http://"+connection.getHostname()+":"+connection.getPort()+"/axis2/services/xdsregistryb"; 
	ActiveParticipant dest = new ActiveParticipant();
	dest.setUserId(userid);
	// the Alternative User ID should be set to our Process ID, see
	// section TF-2b section 3.42.7.1.2
	dest.setAltUserId(PidHelper.getPid());
	
	dest.setAccessPointId(localIP);
	auditLog.logDocumentImport(source, dest, patientObj, set, typeCode);		
}
 
Example #2
Source File: LoadBalanceSessionFullClient.java    From product-ei with Apache License 2.0 6 votes vote down vote up
protected String extractSessionID(MessageContext axis2MessageContext) {

        Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);

        if (o instanceof Map) {
            Map headerMap = (Map) o;
            String cookie = (String) headerMap.get(SET_COOKIE);
            if (cookie == null) {
                cookie = (String) headerMap.get(COOKIE);
            } else {
                cookie = cookie.split(";")[0];
            }
            return cookie;
        }
        return null;
    }
 
Example #3
Source File: AppendixV.java    From openxds with Apache License 2.0 6 votes vote down vote up
protected void checkSOAP12() throws XdsWSException {
	
	if (MessageContext.getCurrentMessageContext().isSOAP11()) {
		throwFault("SOAP 1.1 not supported");
	}
	SOAPEnvelope env = MessageContext.getCurrentMessageContext().getEnvelope();
	if (env == null)
		throwFault("No SOAP envelope found");
	SOAPHeader hdr = env.getHeader();
	if (hdr == null)
		throwFault("No SOAP header found");
	if ( !hdr.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing","Action")).hasNext()) {
		throwFault("WS-Action required in header");
	}

}
 
Example #4
Source File: LoadbalanceFailoverClient.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
protected String extractSessionID(MessageContext axis2MessageContext) {

        Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);

        if (o != null && o instanceof Map) {
            Map headerMap = (Map) o;
            String cookie = (String) headerMap.get(SET_COOKIE);
            if (cookie == null) {
                cookie = (String) headerMap.get(COOKIE);
            } else {
                cookie = cookie.split(";")[0];
            }
            return cookie;
        }
        return null;
    }
 
Example #5
Source File: REQUESTHASHGenerator.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * This is the implementation of the getDigest method and will implement the Extended DOMHASH algorithm based HTTP
 * request identifications. This will consider To address of the request, HTTP headers and XML Payload in generating
 * the digets. So, in effect this will uniquely identify the HTTP request with the same To address, Headers and
 * Payload.
 *
 * @param msgContext - MessageContext on which the XML node identifier will be generated
 * @return Object representing the DOMHASH value of the normalized XML node
 * @throws CachingException if there is an error in generating the digest key
 * @see org.wso2.caching.digest.DigestGenerator #getDigest(org.apache.axis2.context.MessageContext)
 */
public String getDigest(MessageContext msgContext) throws CachingException {
    OMNode body = msgContext.getEnvelope().getBody();
    String toAddress = null;
    if (msgContext.getTo() != null) {
        toAddress = msgContext.getTo().getAddress();
    }
    Map<String, String> headers = (Map) msgContext.getProperty(
            org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
    if (body != null) {
        byte[] digest = null;
        if (toAddress != null) {
            digest = getDigest(body, toAddress, headers, MD5_DIGEST_ALGORITHM);
        } else {
            digest = getDigest(body, MD5_DIGEST_ALGORITHM);
        }
        return digest != null ? getStringRepresentation(digest) : null;
    } else {
        return null;
    }
}
 
Example #6
Source File: APIKeyValidationService.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
private void logMessageDetails(MessageContext messageContext, APIKeyValidationInfoDTO apiKeyValidationInfoDTO) {
    String applicationName = apiKeyValidationInfoDTO.getApplicationName();
    String endUserName = apiKeyValidationInfoDTO.getEndUserName();
    String consumerKey = apiKeyValidationInfoDTO.getConsumerKey();
    Boolean isAuthorize = apiKeyValidationInfoDTO.isAuthorized();
    //Do not change this log format since its using by some external apps
    String logMessage = "";
    if (applicationName != null) {
        logMessage = " , appName=" + applicationName;
    }
    if (endUserName != null) {
        logMessage = logMessage + " , userName=" + endUserName;
    }
    Map headers = (Map) messageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
    String logID = (String) headers.get("activityID");
    if (logID != null) {
        logMessage = logMessage + " , transactionId=" + logID;
    }
    if (consumerKey != null) {
        logMessage = logMessage + " , consumerKey=" + consumerKey;
    }
    logMessage = logMessage + " , isAuthorized=" + isAuthorize;
    logMessage = logMessage + " , responseTime=" + new Date(System.currentTimeMillis());

    log.debug("OAuth token response from keyManager to gateway: " + logMessage);
}
 
Example #7
Source File: IntegratorStatefulHandler.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Finds axis Service and the Operation for DSS requests
 *
 * @param msgContext request message context
 * @throws AxisFault if any exception occurs while finding axis service or operation
 */
private static void dispatchAndVerify(MessageContext msgContext) throws AxisFault {
    requestDispatcher.invoke(msgContext);
    AxisService axisService = msgContext.getAxisService();
    if (axisService != null) {
        httpLocationBasedDispatcher.invoke(msgContext);
        if (msgContext.getAxisOperation() == null) {
            requestURIOperationDispatcher.invoke(msgContext);
        }

        AxisOperation axisOperation;
        if ((axisOperation = msgContext.getAxisOperation()) != null) {
            AxisEndpoint axisEndpoint =
                    (AxisEndpoint) msgContext.getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME);
            if (axisEndpoint != null) {
                AxisBindingOperation axisBindingOperation = (AxisBindingOperation) axisEndpoint
                        .getBinding().getChild(axisOperation.getName());
                msgContext.setProperty(Constants.AXIS_BINDING_OPERATION, axisBindingOperation);
            }
            msgContext.setAxisOperation(axisOperation);
        }
    }
}
 
Example #8
Source File: XMPPConfigurationService.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * @param username
 * @param operation
 * @throws IdentityProviderException
 */
private void checkUserAuthorization(String username, String operation)
        throws IdentityProviderException {
    MessageContext msgContext = MessageContext.getCurrentMessageContext();
    HttpServletRequest request = (HttpServletRequest) msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
    HttpSession httpSession = request.getSession(false);
    if (httpSession != null) {
        String userName = (String) httpSession.getAttribute(ServerConstants.USER_LOGGED_IN);
        if (!username.equals(userName)) {
            throw new IdentityProviderException("Unauthorised action by user " + username
                                                + " to access " + operation);
        }
        return;
    }
    throw new IdentityProviderException("Unauthorised action by user " + username
                                        + " to access " + operation);
}
 
Example #9
Source File: ThrottleConditionEvaluator.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
private boolean isConditionGroupApplicable(org.apache.synapse.MessageContext synapseContext,
                                           AuthenticationContext authenticationContext,
                                           ConditionGroupDTO conditionGroup) {

    ConditionDTO[] conditions = conditionGroup.getConditions();

    boolean evaluationState = true;

    if (conditions.length == 0) {
        evaluationState = false;
    }

    // When multiple conditions have been specified, all the conditions should occur.
    for (ConditionDTO condition : conditions) {
        evaluationState = evaluationState & isConditionApplicable(synapseContext, authenticationContext, condition);

        // If one of the conditions are false, rest will evaluate to false. So no need to check the rest.
        if (!evaluationState) {
            return false;
        }
    }
    return evaluationState;
}
 
Example #10
Source File: InOnlyMEPHandler.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
    if (msgContext.getEnvelope() == null) {
        return InvocationResponse.CONTINUE;
    }
    if (msgContext.getFLOW() != MessageContext.IN_FLOW &&
        msgContext.getFLOW() != MessageContext.IN_FAULT_FLOW) {
        log.error("InOnlyMEPHandler not deployed in IN/IN_FAULT flow. Flow: " +
                  msgContext.getFLOW());
        return InvocationResponse.CONTINUE;
    }
    try {
        msgContext.setProperty(StatisticsConstants.REQUEST_RECEIVED_TIME,
                               "" + System.currentTimeMillis());
    } catch (Throwable e) { // Catching Throwable since exceptions here should not be propagated up
        log.error("Could not call InOnlyMEPHandler.invoke", e);
    }
    return InvocationResponse.CONTINUE;
}
 
Example #11
Source File: DataPublisherUtil.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
public static String getClientIp( MessageContext axis2MsgContext){
    String clientIp;
    Map headers =
            (Map) (axis2MsgContext).getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
    String xForwardForHeader = (String) headers.get(HEADER_X_FORWARDED_FOR);
    if (!StringUtils.isEmpty(xForwardForHeader)){
        clientIp = xForwardForHeader;
        int idx = xForwardForHeader.indexOf(',');
        if (idx > -1) {
            clientIp = clientIp.substring(0, idx);
        }
    }else{
     clientIp = (String) axis2MsgContext.getProperty(MessageContext.REMOTE_ADDR);
    }
    return clientIp;
}
 
Example #12
Source File: GatewayUtils.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * This method handles threat violations. If the request propagates a threat, this method generates
 * an custom exception.
 *
 * @param messageContext contains the message properties of the relevant API request which was
 *                       enabled the regexValidator message mediation in flow.
 * @param errorCode      It depends on status of the error message.
 * @param desc           Description of the error message.It describes the vulnerable type and where it happens.
 * @return here return true to continue the sequence. No need to return any value from this method.
 */
public static boolean handleThreat(org.apache.synapse.MessageContext messageContext,
                                   String errorCode, String desc) {

    messageContext.setProperty(APIMgtGatewayConstants.THREAT_FOUND, true);
    messageContext.setProperty(APIMgtGatewayConstants.THREAT_CODE, errorCode);
    if (messageContext.isResponse()) {
        messageContext.setProperty(APIMgtGatewayConstants.THREAT_MSG, APIMgtGatewayConstants.BAD_RESPONSE);
    } else {
        messageContext.setProperty(APIMgtGatewayConstants.THREAT_MSG, APIMgtGatewayConstants.BAD_REQUEST);
    }
    messageContext.setProperty(APIMgtGatewayConstants.THREAT_DESC, desc);
    Mediator sequence = messageContext.getSequence(APIMgtGatewayConstants.THREAT_FAULT);
    // Invoke the custom error handler specified by the user
    if (sequence != null && !sequence.mediate(messageContext)) {
        // If needed user should be able to prevent the rest of the fault handling
        // logic from getting executed
    }
    return true;
}
 
Example #13
Source File: IdentityProviderService.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * @param username
 * @param operation
 * @throws IdentityProviderException
 */
private void checkUserAuthorization(String username, String operation) throws IdentityProviderException {
    MessageContext msgContext = MessageContext.getCurrentMessageContext();
    HttpServletRequest request = (HttpServletRequest) msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
    HttpSession httpSession = request.getSession(false);

    String tenantFreeUsername = MultitenantUtils.getTenantAwareUsername(username);

    if (httpSession != null) {
        String loggedInUsername = (String) httpSession.getAttribute(ServerConstants.USER_LOGGED_IN);
        if (!tenantFreeUsername.equals(loggedInUsername)) {
            throw new IdentityProviderException("Unauthorised action by user " + username
                                                + " to access " + operation);
        }
    } else {
        throw new IdentityProviderException("Unauthorised action by user " + tenantFreeUsername
                                            + " to access " + operation);
    }
}
 
Example #14
Source File: ThrottleConditionEvaluator.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
private boolean isWithinIP(MessageContext messageContext, ConditionDto.IPCondition ipCondition) {

        String currentIpString = GatewayUtils.getIp(messageContext);
        boolean status;
        if (StringUtils.isNotEmpty(currentIpString)) {
            BigInteger currentIp = APIUtil.ipToBigInteger(currentIpString);
            status = ipCondition.getStartingIp().compareTo(currentIp) <= 0
                    && ipCondition.getEndingIp().compareTo(currentIp) >= 0;
        } else {
            return false;
        }
        if (ipCondition.isInvert()) {
            return !status;
        } else {
            return status;
        }
    }
 
Example #15
Source File: GatewayUtils.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * return existing correlation ID in the message context or set new correlation ID to the message context.
 *
 * @param messageContext synapse message context
 * @return correlation ID
 */
public static String getAndSetCorrelationID(org.apache.synapse.MessageContext messageContext) {

    Object correlationObj = messageContext.getProperty(APIMgtGatewayConstants.AM_CORRELATION_ID);
    String correlationID;
    if (correlationObj != null) {
        correlationID = (String) correlationObj;
    } else {
        correlationID = UUID.randomUUID().toString();
        messageContext.setProperty(APIMgtGatewayConstants.AM_CORRELATION_ID, correlationID);
        if (log.isDebugEnabled()) {
            log.debug("Setting correlation ID to message context.");
        }
    }
    return correlationID;
}
 
Example #16
Source File: TracerUtils.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Get a prettified XML string from the SOAPEnvelope
 *
 * @param env        The SOAPEnvelope to be prettified
 * @param msgContext The MessageContext
 * @return prettified XML string from the SOAPEnvelope
 */
public static String getPrettyString(OMElement env, MessageContext msgContext) {
    String xml;
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        env.serialize(baos);
        InputStream xmlIn = new ByteArrayInputStream(baos.toByteArray());
        String encoding =
                (String) msgContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
        XMLPrettyPrinter xmlPrettyPrinter = new XMLPrettyPrinter(xmlIn, encoding);
        xml = xmlPrettyPrinter.xmlFormat();
    } catch (Throwable e) {
        String error = "Error occurred while pretty printing message. " + e.getMessage();
        log.error(error, e);
        xml = error;
    }
    return xml;
}
 
Example #17
Source File: AbstractAdmin.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void checkAdminService() {
    MessageContext msgCtx = MessageContext.getCurrentMessageContext();
    if (msgCtx == null) {
        return;
    }
    AxisService axisService = msgCtx.getAxisService();
    if (axisService.getParameter(Constants.ADMIN_SERVICE_PARAM_NAME) == null) {
        throw new RuntimeException(
                "AbstractAdmin can only be extended by Carbon admin services. " + getClass().getName()
                        + " is not an admin service. Service name " + axisService.getName()
                        + ". The service should have defined the " + Constants.ADMIN_SERVICE_PARAM_NAME
                        + " parameter");
    }
}
 
Example #18
Source File: PublishOnlyMessageReceiver.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
private boolean isEnabled(MessageContext mc, String operation) {
    if (mc.getAxisService() != null) {
        String operationValue =
                (String) mc.getAxisService().getParameterValue(operation);
        return operationValue == null || !operationValue.toLowerCase().equals(
                Boolean.toString(false));
    }
    return true;
}
 
Example #19
Source File: TracingInPostDispatchHandler.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Store the received message
 *
 * @param operationName operationName
 * @param serviceName   serviceName
 * @param msgCtxt       msgCtxt
 * @return the sequence of the message stored with respect to the operation
 *         in the service
 */
protected long storeMessage(String serviceName,
                            String operationName,
                            MessageContext msgCtxt) {
    TracePersister tracePersister =
        (TracePersister) msgCtxt.getConfigurationContext().getAxisConfiguration()
                                .getParameter(TracerConstants.TRACE_PERSISTER_IMPL).getValue();
    return tracePersister.saveMessage(serviceName, operationName,
                                      msgCtxt.getFLOW(), msgCtxt,
                                      (OMElement) msgCtxt.getProperty(TracerConstants.TEMP_IN_ENVELOPE),
                                      -1); // Use the temp envelope
}
 
Example #20
Source File: TestImpl11710.java    From openxds with Apache License 2.0 5 votes vote down vote up
public TestImpl11710(LogMessage log_message, short xds_version, MessageContext messageContext) {
	this.log_message = log_message;
	this.xds_version = xds_version;
	this.messageContext = messageContext;
	transaction_type = OTHER_transaction;
	try {
		init(new RegistryResponse( (xds_version == xds_a) ?	Response.version_2 : Response.version_3), xds_version, messageContext);
	} catch (XdsInternalException e) {
		System.out.println("Internal Error creating RegistryResponse: " + e.getMessage());
	}
}
 
Example #21
Source File: SignedJWTAuthenticator.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isHandle(MessageContext msgCxt) {
    HttpServletRequest request =
            (HttpServletRequest) msgCxt.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
    String authorizationHeader = request.getHeader(HTTPConstants.HEADER_AUTHORIZATION);
    if (authorizationHeader != null) {
        String authType = getAuthType(authorizationHeader);
        if (authType != null && authType.equalsIgnoreCase(AUTHORIZATION_HEADER_TYPE)) {
            return true;
        }
    }
    return false;
}
 
Example #22
Source File: InboundHttpServerWorker.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Checks whether the given proxy is deployed in synapse environment
 *
 * @param synapseContext Synapse Message Context of incoming message
 * @param serviceOpPart  String name of the service operation
 * @return true if the proxy is deployed, false otherwise
 */
private boolean isProxyDeployed(org.apache.synapse.MessageContext synapseContext, String serviceOpPart) {
    boolean isDeployed = false;

    //extract proxy name from serviceOperation, get the first portion split by '/'
    String proxyName = serviceOpPart.split("/")[0];

    //check whether the proxy is deployed in synapse environment
    if (synapseContext.getConfiguration().getProxyService(proxyName) != null) {
        isDeployed = true;
    }
    return isDeployed;
}
 
Example #23
Source File: JMSUtils.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private static boolean isHyphenReplaceMode(MessageContext msgContext) {
    if (msgContext == null) {
        return false;
    }

    String hyphenSupport = (String) msgContext.getProperty(JMSConstants.PARAM_JMS_HYPHEN_MODE);
    if (hyphenSupport != null && hyphenSupport.equals(JMSConstants.HYPHEN_MODE_REPLACE)) {
        return true;
    }

    return false;
}
 
Example #24
Source File: ThrottleConditionEvaluator.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
private boolean isWithinIP(MessageContext messageContext, ConditionDTO condition) {
    // For an IP Range Condition, starting IP is set as a the name, ending IP as the value.
    BigInteger startIp = APIUtil.ipToBigInteger(condition.getConditionName());
    BigInteger endIp = APIUtil.ipToBigInteger(condition.getConditionValue());

    String currentIpString = GatewayUtils.getIp(messageContext);
    if (!currentIpString.isEmpty()) {
        BigInteger currentIp = APIUtil.ipToBigInteger(currentIpString);

        return startIp.compareTo(currentIp) <= 0 && endIp.compareTo(currentIp) >= 0;
    }
    return false;
}
 
Example #25
Source File: CarbonEventingMessageReceiver.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Dispatch the message to the target endpoint
 *
 * @param soapEnvelope   Soap Enevlop with message
 * @param responseAction WSE action for the response
 * @param mc             Message Context
 * @param isFault        Whether a Fault message must be sent
 * @throws AxisFault Thrown by the axis2 engine.
 */
private void dispatchResponse(SOAPEnvelope soapEnvelope, String responseAction,
                              MessageContext mc, boolean isFault) throws AxisFault {
    MessageContext rmc = MessageContextBuilder.createOutMessageContext(mc);
    rmc.getOperationContext().addMessageContext(rmc);
    replicateState(mc);
    rmc.setEnvelope(soapEnvelope);
    rmc.setWSAAction(responseAction);
    rmc.setSoapAction(responseAction);
    if (isFault) {
        AxisEngine.sendFault(rmc);
    } else {
        AxisEngine.send(rmc);
    }
}
 
Example #26
Source File: UnSubscribeCommandBuilderTest.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public void testSubscriptionToSOAP12Envelope() throws Exception {
    Subscription subscription = new Subscription();
    MessageContext mc = CommandBuilderTestUtils.getMCWithSOAP12Envelope();
    UnSubscribeCommandBuilder builder = new  UnSubscribeCommandBuilder(mc);

    OMElement payload = builder.fromSubscription(subscription);
    System.out.println("[TODO] The UnSubscribe Response is not compatible with the WS-Eventing " +
            "specification.\nFind a solution to this and enable the assertion.");
    /*assertEquals("Invalid response for the get status request", RESPONSE_PAYLOAD_SOAP12,
            payload.toString());*/
}
 
Example #27
Source File: ProxyMessageReceiver.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
private SOAPEnvelope getResponseEnvelope(ServiceClient client) throws AxisFault {
    OperationContext operationContext = client.getLastOperationContext();
    MessageContext messageContext =
            operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    if (messageContext != null) {
        return messageContext.getEnvelope();
    }
    return null;
}
 
Example #28
Source File: ODataServletResponse.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Override
public void addHeader(String headerName, String headerValue) {
    Object o = axis2MessageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
    Map headers = (Map) o;
    if (headers != null) {
        headers.put(headerName, headerValue);
    }
    if (HTTP.CONTENT_TYPE.equals(headerName)) {
        contentType = headerValue;
    }
    if (HTTP.CONTENT_LEN.equals(headerName)) {
        contentLength = Long.parseLong(headerValue);
    }
}
 
Example #29
Source File: AxisOperationClient.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param trpUrl
 * @param addUrl
 * @param payload
 * @param action
 * @return   soap envelop
 * @throws org.apache.axis2.AxisFault
 */

public OMElement send(String trpUrl, String addUrl, OMElement payload, String action) throws AxisFault {
    operationClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
    setMessageContext(addUrl, trpUrl, action);
    outMsgCtx.setEnvelope(createSOAPEnvelope(payload));
    operationClient.addMessageContext(outMsgCtx);
    operationClient.execute(true);
    MessageContext inMsgtCtx = operationClient.getMessageContext("In");
    SOAPEnvelope response = inMsgtCtx.getEnvelope();
    return response;
}
 
Example #30
Source File: AbstractTracingHandler.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Store the received message
 *
 * @param operationName operationName
 * @param serviceName   serviceName
 * @param msgCtxt       msgCtxt
 * @return the sequence of the message stored with respect to the operation
 *         in the service
 */
protected long storeMessage(String serviceName,
                            String operationName,
                            MessageContext msgCtxt,
                            long msgSequenceNumber) {
    TracePersister tracePersister =
        (TracePersister) msgCtxt.getConfigurationContext().
            getAxisConfiguration().getParameter(TracerConstants.TRACE_PERSISTER_IMPL).getValue();
    return tracePersister.saveMessage(serviceName, operationName,
                                      msgCtxt.getFLOW(),
                                      msgCtxt,
                                      msgCtxt.getEnvelope().cloneOMElement(), msgSequenceNumber);
}