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;
}
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);
}
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;
}
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;
}
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"));
}
Aggregations