Index: src/main/java/org/jboss/injection/WebServiceContextPropertyInjector.java
===================================================================
--- src/main/java/org/jboss/injection/WebServiceContextPropertyInjector.java	(revision 112869)
+++ src/main/java/org/jboss/injection/WebServiceContextPropertyInjector.java	(working copy)
@@ -32,7 +32,7 @@
  * @author Thomas.Diesler@jboss.com
  * @version $Revision: $
  */
-public class WebServiceContextPropertyInjector implements Injector
+public class WebServiceContextPropertyInjector implements Injector, PojoInjector
 {
    private BeanProperty property;
    
@@ -57,7 +57,13 @@
       
       ((StatelessBeanContext)ctx).setWebServiceContextProperty(property);
    }
-   
+
+   @Override
+   public void inject(final BeanContext ctx, final Object instance)
+   {
+      property.set(instance, new WebServiceContextProxy());
+   }
+
    public Class getInjectionClass()
    {
       return property.getType();
Index: src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	(revision 112869)
+++ src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	(working copy)
@@ -721,12 +721,12 @@
          StatelessBeanContext sbc = (StatelessBeanContext)beanCtx;
          sbc.setMessageContextJAXRPC(jaxrpcMessageContext);
 
+         EJBContext ejbCtx = beanCtx.getEJBContext();
+         jaxwsContext.addAttachment(EJBContext.class, ejbCtx);
          // JAX-WS MessageContext
          BeanProperty beanProp = sbc.getWebServiceContextProperty();
          if (beanProp != null)
          {
-            EJBContext ejbCtx = beanCtx.getEJBContext();            
-            jaxwsContext.addAttachment(EJBContext.class, ejbCtx);
             beanProp.set(beanCtx.getInstance(), jaxwsContext);
          }
       }
Index: src/test/java/org/jboss/ejb3/core/test/jbpapp4428/WebServiceMockStateless.java
===================================================================
--- src/test/java/org/jboss/ejb3/core/test/jbpapp4428/WebServiceMockStateless.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/core/test/jbpapp4428/WebServiceMockStateless.java	(revision 0)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.jbpapp4428;
+
+/**
+ * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
+ */
+public interface WebServiceMockStateless
+{
+   void fail();
+
+   void succeed();
+}
Index: src/test/java/org/jboss/ejb3/core/test/jbpapp4428/MockSPIProviderResolver.java
===================================================================
--- src/test/java/org/jboss/ejb3/core/test/jbpapp4428/MockSPIProviderResolver.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/core/test/jbpapp4428/MockSPIProviderResolver.java	(revision 0)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.jbpapp4428;
+
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.invocation.ExtensibleWebServiceContext;
+import org.jboss.wsf.spi.invocation.InvocationType;
+import org.jboss.wsf.spi.invocation.WebServiceContextEJB;
+import org.jboss.wsf.spi.invocation.WebServiceContextFactory;
+
+import javax.xml.ws.handler.MessageContext;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
+ */
+public class MockSPIProviderResolver extends SPIProviderResolver
+{
+   private static final Map<Class<?>, Object> SPIS = new HashMap<Class<?>, Object>();
+
+   private static final SPIProvider INSTANCE = new SPIProvider()
+   {
+      @Override
+      public <T> T getSPI(Class<T> tClass)
+      {
+         return tClass.cast(SPIS.get(tClass));
+      }
+   };
+
+   static
+   {
+      SPIS.put(WebServiceContextFactory.class, new WebServiceContextFactory()
+      {
+         @Override
+         public ExtensibleWebServiceContext newWebServiceContext(InvocationType invocationType, MessageContext messageContext)
+         {
+            return new WebServiceContextEJB(messageContext);
+         }
+      });
+   }
+
+   @Override
+   public SPIProvider getProvider()
+   {
+      return INSTANCE;
+   }
+}
Index: src/test/java/org/jboss/ejb3/core/test/jbpapp4428/WebServiceMockStatelessBean.java
===================================================================
--- src/test/java/org/jboss/ejb3/core/test/jbpapp4428/WebServiceMockStatelessBean.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/core/test/jbpapp4428/WebServiceMockStatelessBean.java	(revision 0)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.jbpapp4428;
+
+import org.jboss.ejb3.annotation.SecurityDomain;
+
+import javax.ejb.Stateless;
+import javax.interceptor.Interceptors;
+
+/**
+ * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
+ */
+@Stateless
+@Interceptors(WebServiceContextMucker.class)
+@SecurityDomain(value="test", unauthenticatedPrincipal="nobody")
+public class WebServiceMockStatelessBean implements WebServiceMockStateless
+{
+   @Override
+   public void fail()
+   {
+      throw new RuntimeException("Should have been intercepted");
+   }
+
+   @Override
+   public void succeed()
+   {
+      throw new RuntimeException("Should have been intercepted");
+   }
+}
Index: src/test/java/org/jboss/ejb3/core/test/jbpapp4428/WebServiceContextMucker.java
===================================================================
--- src/test/java/org/jboss/ejb3/core/test/jbpapp4428/WebServiceContextMucker.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/core/test/jbpapp4428/WebServiceContextMucker.java	(revision 0)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.jbpapp4428;
+
+import javax.annotation.Resource;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import javax.xml.ws.WebServiceContext;
+
+/**
+ * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
+ */
+public class WebServiceContextMucker
+{
+   @Resource
+   private WebServiceContext ctx;
+
+   @AroundInvoke
+   public Object aroundInvoke(final InvocationContext context) throws Exception
+   {
+      final String methodName = context.getMethod().getName();
+      if (methodName.equals("fail"))
+      {
+         try
+         {
+            ctx.getMessageContext();
+            throw new RuntimeException("ctx.getMessageContext() should have failed");
+         }
+         catch (IllegalStateException e)
+         {
+            // good
+            return null;
+         }
+      }
+      ctx.getUserPrincipal();
+      return null;
+   }
+}
Index: src/test/java/org/jboss/ejb3/core/test/jbpapp4428/unit/MockWebServiceInvocationTestCase.java
===================================================================
--- src/test/java/org/jboss/ejb3/core/test/jbpapp4428/unit/MockWebServiceInvocationTestCase.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/core/test/jbpapp4428/unit/MockWebServiceInvocationTestCase.java	(revision 0)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (c) 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.jbpapp4428.unit;
+
+import org.jboss.ejb3.core.test.common.AbstractEJB3TestCase;
+import org.jboss.ejb3.core.test.jbpapp4428.MockSPIProviderResolver;
+import org.jboss.ejb3.core.test.jbpapp4428.WebServiceMockStateless;
+import org.jboss.ejb3.core.test.jbpapp4428.WebServiceMockStatelessBean;
+import org.jboss.ejb3.stateless.StatelessContainer;
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityContextAssociation;
+import org.jboss.security.SecurityContextFactory;
+import org.jboss.security.SecurityContextUtil;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.wsf.spi.invocation.integration.InvocationContextCallback;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.security.auth.Subject;
+import java.lang.reflect.Method;
+import java.security.Principal;
+
+/**
+ * This test mimics the way WS calls into EJB3.
+ *
+ * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
+ */
+public class MockWebServiceInvocationTestCase extends AbstractEJB3TestCase
+{
+   private static StatelessContainer container;
+
+   @AfterClass
+   public static void afterClass() throws Exception
+   {
+      undeployEjb(container);
+
+      AbstractEJB3TestCase.afterClass();
+   }
+
+   @BeforeClass
+   public static void beforeClass() throws Exception
+   {
+      System.setProperty("org.jboss.wsf.spi.SPIProviderResolver", MockSPIProviderResolver.class.getName());
+
+      AbstractEJB3TestCase.beforeClass();
+
+      deploy("securitymanager-beans.xml");
+
+      container = (StatelessContainer) deploySessionEjb(WebServiceMockStatelessBean.class);
+      container.setJaccContextId("test");
+   }
+
+   private SecurityContext login(String name, Object credential) throws Exception
+   {
+      SecurityContext sc = SecurityContextFactory.createSecurityContext("test");
+      SecurityContextUtil util = sc.getUtil();
+      Principal principal = new SimplePrincipal(name);
+      Subject subject = new Subject();
+      subject.getPrincipals().add(principal);
+      subject.getPrivateCredentials().add(credential);
+      util.createSubjectInfo(principal, credential, subject);
+      SecurityContextAssociation.setSecurityContext(sc);
+      return sc;
+   }
+
+   @Test
+   public void testFail() throws Throwable
+   {
+      final SecurityContext sc = SecurityContextFactory.createSecurityContext("test");
+      SecurityContextAssociation.setSecurityContext(sc);
+
+      WebServiceMockStateless bean = lookup(WebServiceMockStatelessBean.class.getSimpleName() + "/local", WebServiceMockStateless.class);
+      bean.fail();
+   }
+
+   @Test
+   public void testSucceed() throws Throwable
+   {
+      final SecurityContext sc = SecurityContextFactory.createSecurityContext("test");
+      SecurityContextAssociation.setSecurityContext(sc);
+
+      final Method method = WebServiceMockStateless.class.getDeclaredMethod("succeed");
+      final Object[] args = null;
+      final InvocationContextCallback invCtxCallback = new InvocationContextCallback()
+      {
+         @Override
+         public <T> T get(Class<T> tClass)
+         {
+            return null;
+         }
+      };
+      container.invokeEndpoint(method, args, invCtxCallback);
+   }
+}
