Search in sources :

Example 16 with ServiceContext

use of org.apache.axis2.context.ServiceContext in project core-util by WSO2Telco.

the class OAuthApplicationData method getApplicationData.

public OAuthConsumerAppDTO getApplicationData(String appId) throws PCRException {
    OAuthConsumerAppDTO apps = null;
    OAuthAdminServiceStub oAuthAdminServiceStub;
    try {
        if (DEBUG)
            log.debug("initializing the o Auth Admin Service stub");
        Object stub = this.stubs.borrowObject();
        if (stub != null) {
            oAuthAdminServiceStub = (OAuthAdminServiceStub) stub;
            if (cookie != null) {
                oAuthAdminServiceStub._getServiceClient().getOptions().setProperty(HTTPConstants.COOKIE_STRING, cookie);
            }
            apps = oAuthAdminServiceStub.getOAuthApplicationData(appId);
            // apps = oAuthAdminServiceStub.getAllOAuthApplicationData();
            ServiceContext serviceContext = oAuthAdminServiceStub._getServiceClient().getLastOperationContext().getServiceContext();
            cookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING);
        } else {
            log.warn("Stub initialization failed.");
        }
    } catch (Exception e) {
        log.error("error initializing the stub", e);
        throw new PCRException("error initializing the stub");
    }
    return apps;
}
Also used : OAuthAdminServiceStub(org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceStub) ServiceContext(org.apache.axis2.context.ServiceContext) PCRException(com.wso2telco.core.pcrservice.exception.PCRException) OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) PCRException(com.wso2telco.core.pcrservice.exception.PCRException)

Example 17 with ServiceContext

use of org.apache.axis2.context.ServiceContext in project carbon-business-process by wso2.

the class AxisServiceUtils method getOperationClient.

private static OperationClient getOperationClient(ServiceInvocationContext partnerMessageContext, ConfigurationContext clientConfigCtx) throws AxisFault {
    AxisService anonymousService = AnonymousServiceFactory.getAnonymousService(partnerMessageContext.getService(), partnerMessageContext.getPort(), clientConfigCtx.getAxisConfiguration(), partnerMessageContext.getCaller());
    anonymousService.engageModule(clientConfigCtx.getAxisConfiguration().getModule("UEPModule"));
    anonymousService.getParent().addParameter("hiddenService", "true");
    ServiceGroupContext sgc = new ServiceGroupContext(clientConfigCtx, (AxisServiceGroup) anonymousService.getParent());
    ServiceContext serviceCtx = sgc.getServiceContext(anonymousService);
    // get a reference to the DYNAMIC operation of the Anonymous Axis2 service
    AxisOperation axisAnonymousOperation = anonymousService.getOperation(partnerMessageContext.isTwoWay() ? ServiceClient.ANON_OUT_IN_OP : ServiceClient.ANON_OUT_ONLY_OP);
    Options clientOptions = cloneOptions(partnerMessageContext.getInMessageContext().getOptions());
    clientOptions.setExceptionToBeThrownOnSOAPFault(false);
    /* This value doesn't overrideend point config. */
    clientOptions.setTimeOutInMilliSeconds(60000);
    return axisAnonymousOperation.createClient(serviceCtx, clientOptions);
}
Also used : Options(org.apache.axis2.client.Options) AxisOperation(org.apache.axis2.description.AxisOperation) ServiceGroupContext(org.apache.axis2.context.ServiceGroupContext) ServiceContext(org.apache.axis2.context.ServiceContext) AxisService(org.apache.axis2.description.AxisService)

Example 18 with ServiceContext

use of org.apache.axis2.context.ServiceContext in project carbon-apimgt by wso2.

the class GlobalThrottleEngineClient method login.

private String login() throws RemoteException, LoginAuthenticationExceptionException, MalformedURLException {
    authenticationAdminStub = getAuthenticationAdminStub();
    String sessionCookie = null;
    if (authenticationAdminStub.login(getPolicyDeployer().getUsername(), getPolicyDeployer().getPassword(), getHost())) {
        ServiceContext serviceContext = authenticationAdminStub._getServiceClient().getLastOperationContext().getServiceContext();
        sessionCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING);
    }
    return sessionCookie;
}
Also used : ServiceContext(org.apache.axis2.context.ServiceContext)

Example 19 with ServiceContext

use of org.apache.axis2.context.ServiceContext in project wso2-synapse by wso2.

the class Axis2SynapseEnvironment method createMessageContext.

/**
 * This method will be used to create a new MessageContext in the Axis2 environment for
 * Synapse. This will set all the relevant parts to the MessageContext, but for this message
 * context to be useful creator has to fill in the data like envelope and operation context
 * and so on. This will set a default envelope of type soap12 and a new messageID for the
 * created message along with the ConfigurationContext is being set in to the message
 * correctly.
 *
 * @return Synapse MessageContext with the underlying axis2 message context set
 */
public MessageContext createMessageContext() {
    if (log.isDebugEnabled()) {
        log.debug("Creating Message Context");
    }
    org.apache.axis2.context.MessageContext axis2MC = new org.apache.axis2.context.MessageContext();
    axis2MC.setConfigurationContext(this.configContext);
    ServiceContext svcCtx = new ServiceContext();
    OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx);
    axis2MC.setServiceContext(svcCtx);
    axis2MC.setOperationContext(opCtx);
    MessageContext mc = new Axis2MessageContext(axis2MC, synapseConfig, this);
    mc.setMessageID(UIDGenerator.generateURNString());
    try {
        mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope());
        mc.getEnvelope().addChild(OMAbstractFactory.getSOAP12Factory().createSOAPBody());
    } catch (Exception e) {
        handleException("Unable to attach the SOAP envelope to " + "the created new message context", e);
    }
    return mc;
}
Also used : OperationContext(org.apache.axis2.context.OperationContext) ServiceContext(org.apache.axis2.context.ServiceContext) MessageContext(org.apache.synapse.MessageContext) InOutAxisOperation(org.apache.axis2.description.InOutAxisOperation) SynapseException(org.apache.synapse.SynapseException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 20 with ServiceContext

use of org.apache.axis2.context.ServiceContext in project wso2-synapse by wso2.

the class DeliveryAgentTest method test.

/**
 * This method tests whether the message is queued by the delivery agent when the connection is null
 *
 * @throws Exception
 */
@Test
public void test() throws Exception {
    MessageContext messageContext = new MessageContext();
    ServiceContext svcCtx = new ServiceContext();
    OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx);
    messageContext.setServiceContext(svcCtx);
    messageContext.setOperationContext(opCtx);
    TargetConfiguration targetConfiguration = PowerMockito.mock(TargetConfiguration.class);
    TargetConnections conns = PowerMockito.mock(TargetConnections.class);
    ProxyConfig config = PowerMockito.mock(ProxyConfig.class);
    EndpointReference epr = new EndpointReference("http://127.0.0.1:3001/services");
    DeliveryAgent agent = new DeliveryAgent(targetConfiguration, conns, config);
    agent.submit(messageContext, epr);
    Assert.assertEquals("127.0.0.1", messageContext.getProperty("PROXY_PROFILE_TARGET_HOST"));
}
Also used : OperationContext(org.apache.axis2.context.OperationContext) TargetConfiguration(org.apache.synapse.transport.passthru.config.TargetConfiguration) ServiceContext(org.apache.axis2.context.ServiceContext) MessageContext(org.apache.axis2.context.MessageContext) ProxyConfig(org.apache.synapse.transport.http.conn.ProxyConfig) TargetConnections(org.apache.synapse.transport.passthru.connections.TargetConnections) InOutAxisOperation(org.apache.axis2.description.InOutAxisOperation) EndpointReference(org.apache.axis2.addressing.EndpointReference) Test(org.junit.Test)

Aggregations

ServiceContext (org.apache.axis2.context.ServiceContext)24 OperationContext (org.apache.axis2.context.OperationContext)15 InOutAxisOperation (org.apache.axis2.description.InOutAxisOperation)14 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)12 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)11 AxisService (org.apache.axis2.description.AxisService)10 MessageContext (org.apache.synapse.MessageContext)10 ServiceGroupContext (org.apache.axis2.context.ServiceGroupContext)9 AxisOperation (org.apache.axis2.description.AxisOperation)8 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)8 EndpointReference (org.apache.axis2.addressing.EndpointReference)6 Options (org.apache.axis2.client.Options)6 SynapseException (org.apache.synapse.SynapseException)6 MessageContext (org.apache.axis2.context.MessageContext)5 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)5 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)5 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)4 Test (org.junit.Test)4 Map (java.util.Map)3 QName (javax.xml.namespace.QName)3