users@glassfish.java.net

Cannot get SOAPMessage from the PolicyContext.getContext call inside WS

From: <glassfish_at_javadesktop.org>
Date: Fri, 20 Apr 2007 04:31:17 PDT

Hello,
I'm using GlassFish V2 Beta 1 and trying to experiment with WebServices on this platform. I'm using Java EE 5 tutorial example: Basic Authentication with JAX-WS, which s described here:
http://java.sun.com/javaee/5/docs/tutorial/doc/Security-WebTier6.html#wp569399

I've modified the service code to show the SOAPMessage object get from the PolicyContext.getContext call:

@WebService
public class Hello {
private String message = new String("Hello, ");

@WebMethod
@RolesAllowed("basicUser")
public String sayHello(String name) {
System.err.println("::::WWWSSS:::: sayHello is invoked!");
try {
Subject subj = (Subject) PolicyContext.getContext("javax.security.auth.Subject.container");
System.err.println("....invoked by: " + subj);
Object obj = PolicyContext.getContext("javax.xml.soap.SOAPMessage");
if (obj != null) {
SOAPMessage msg = (SOAPMessage)obj;
System.err.println("SOAP msg: " + msg);
}
else
System.err.println("This is not SOAP message!");
} catch (PolicyContextException ex) {
ex.printStackTrace();
}
return message + name + ".";
}
}

the problem is that although the example is a webservice, I'm not able to get SOAPMessage here and the server always in log prints the message:

This is not SOAP message!

My question is: is this a bug in Glassfish or is my assumption wrong and I might get content of SOAP message in somewhat different way?

Thanks,
Karel
[Message sent by forum member 'kgardas' (kgardas)]

http://forums.java.net/jive/thread.jspa?messageID=213351