use of javax.xml.rpc.handler.MessageContext in project wildfly by wildfly.
the class SessionContextImpl method getMessageContext.
public MessageContext getMessageContext() throws IllegalStateException {
final InterceptorContext invocation = CurrentInvocationContext.get();
final MessageContext context = invocation.getPrivateData(MessageContext.class);
if (context == null) {
throw EjbLogger.ROOT_LOGGER.cannotCall("getMessageContext()", "MessageContext");
}
return context;
}
use of javax.xml.rpc.handler.MessageContext in project tomee by apache.
the class JaxRpcInvocationTest method testWebServiceInvocations.
public void testWebServiceInvocations() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class, "PseudoSecurityService", null, "PseudoSecurityService", null));
assembler.createContainer(config.configureService(StatelessSessionContainerInfo.class));
final EjbJarInfo ejbJar = config.configureApplication(buildTestApp());
assembler.createApplication(ejbJar);
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
final BeanContext beanContext = containerSystem.getBeanContext("EchoBean");
assertNotNull(beanContext);
assertEquals("ServiceEndpointInterface", EchoServiceEndpoint.class, beanContext.getServiceEndpointInterface());
// OK, Now let's fake a web serivce invocation coming from any random
// web service provider. The web serivce provider needs supply
// the MessageContext and an interceptor to do the marshalling as
// the arguments of the standard container.invoke signature.
// So let's create a fake message context.
final MessageContext messageContext = new FakeMessageContext();
// Now let's create a fake interceptor as would be supplied by the
// web service provider. Instead of writing "fake" marshalling
// code that would pull the arguments from the soap message, we'll
// just give it the argument values directly.
final Object wsProviderInterceptor = new FakeWsProviderInterceptor("Hello world");
// Ok, now we have the two arguments expected on a JAX-RPC Web Service
// invocation as per the OpenEJB-specific agreement between OpenEJB
// and the Web Service Provider
final Object[] args = new Object[] { messageContext, wsProviderInterceptor };
// Let's grab the container as the Web Service Provider would do and
// perform an invocation
final RpcContainer container = (RpcContainer) beanContext.getContainer();
final Method echoMethod = EchoServiceEndpoint.class.getMethod("echo", String.class);
final String value = (String) container.invoke("EchoBean", InterfaceType.SERVICE_ENDPOINT, echoMethod.getDeclaringClass(), echoMethod, args, null);
assertCalls(Call.values());
calls.clear();
assertEquals("Hello world", value);
}
use of javax.xml.rpc.handler.MessageContext in project tomee by apache.
the class BaseSessionContext method getMessageContext.
public MessageContext getMessageContext() throws IllegalStateException {
doCheck(Call.getMessageContext);
final ThreadContext threadContext = ThreadContext.getThreadContext();
final MessageContext messageContext = threadContext.get(MessageContext.class);
if (messageContext == null) {
throw new IllegalStateException("Only calls on the service-endpoint have a MessageContext.");
}
return messageContext;
}
Aggregations