Troubleshooting JAXWS Message Level Security in GlassFish
Friday Mar 16, 2007
In Java EE 5,
one can implement JAXWS Web Services through servlets and Ejb
endpoints (JSR 109).
GlassFish
supports message level security for Web Services.
You don't need to write special client and server Java code in
order to take advantages of the message level security. What you
need to do is specific a corresponding message-level-security
element in sun-ejb-jar.xml, sun-web.xml,
and sun-application.xml.
For instance,
<webservice-endpoint>
<port-component-name>PingEjb</port-component-name>
<endpoint-address-uri>/PingEjbService/PingEjb</endpoint-address-uri>
<message-security-binding auth-layer="SOAP" provider-id="XWS_ServerProvider">
<message-security>
<message/>
<request-protection auth-source="sender"/>
<response-protection auth-source="content"/>
</message-security>
</message-security-binding>
</webservice-endpoint>
Or you can turn on the default in domain.xml for
server side or sun-acc.xml for appclient.
This blog will highlight some troubleshootings for JAXWS message level security.
Read logs
- Look at client and server logs.
The server log is located at
$GLASSFISH_HOME/domains/your_domain/logs/server.log. - If you want to see more SOAP level debug info, like
corresponding SOAP messages, then you can turn on provider's debug.
For server and embedded client, one can achieve this by navigating from admin console:Configuration > Security > Message Security > SOAP > Providers:- For server, choose the provider
XWS_ServerProvider, change thedebugproperty totrueand save the configuration. - For embedded client, choose the provider
XWS_ClientProvider, change thedebugproperty totrueand save the configuration.
debugproperty totruefor the providerXWS_ClientProvider, andlog-service leveltoINFO. - For server, choose the provider
Endpoint info mismatch
For message level security, one need to ensure that the same
request-policy and response-policy
are applied to both client and server. These info can be
specified in sun-*.xml for a given application
or domain.xml and sun-acc.xml for default
provider configuration (if default is on).
If you see com.sun.xml.wss.impl.PolicyViolationException:
Expected Signature Element as per receiver requirements
or there is no security processing in SOAP message in debug log,
then most probably some of the info about endpoint in
sun-*.xml is not correct. You may like to double
check each port-component-name (defined in
JSR 109) and
endpoint-address-uri inside
message-security-binding in sun-*.xml
are correct.
Note:
- According to JSR 181,
we have the following:
Value Default @WebService.name Simple name of the Java class or interface @WebService.serviceName Simple name of the Java class + "Service"
- In GlassFish, the URL to access WebService and
endpoint-address-uriinsun-*.xmlare related as follows:Endpoint Type WebService URL Servlet http[s]://host:port/context-root/ endpoint-address-uriEjb http[s]://host:port/ endpoint-address-uri
- One can also find out the
port-component-nameby checking the generatedwebservices.xmlin admin console as follows:Web Services > YOUR_WEB_SERVICES > Webservices.xml, and then correct theport-component-name, repackage and redeploy your application if necessary.











I've been trying to get this work by using sun-web...
In c...
I am using netbeans 6.5 and glassfisn v2u2/sun app...
To get rid of the error message posted in my previ...
Here is my section I manually added to my sun-web....
Hi. We have a custom Jaspi SAM for a propietary SS...