title: How to get username with symmetric key work?
body: <p>I have web service that wrap an ejb layer that use roleallowed annotation and jdbc realm .
  In order to make the client authentification work from my swing client I Enabled Username authentication with symmetric keys (client+server) and set up my callback handler (client) .
  When I run the client and try to acces a protected method I get this exception :</p>
  
  <pre><code>Grave: WSSTUBE0025: Error in Verifying Security in the Inbound Message.
  com.sun.xml.wss.impl.PolicyViolationException: ERROR: No security header found in the message
      at com.sun.xml.wss.impl.policy.verifier.MessagePolicyVerifier.verifyPolicy(MessagePolicyVerifier.java:138)
      at com.sun.xml.ws.security.opt.impl.incoming.SecurityRecipient.createMessage(SecurityRecipient.java:1003)
      at com.sun.xml.ws.security.opt.impl.incoming.SecurityRecipient.validateMessage(SecurityRecipient.java:248)
  </code></pre>
  
  <p>and in server side i get :</p>
  
  <pre><code>Key used to decrypt EncryptedKey cannot be null
  com.sun.xml.wss.logging.impl.opt.crypto Error occured while decrypting EncryptedKey     
  
  
  WSITPVD0035: Error in Verifying Security in Inbound Message. com.sun.xml.wss.impl.WssSoapFaultException: Invalid Security Header at 
  </code></pre>
  
  <p>and </p>
  
  <pre><code>com.sun.xml.ws.security.opt.impl.util.SOAPUtil.newSOAPFaultException(SOAPUtil.java:159) at 
      com.sun.xml.ws.security.opt.impl.incoming.EncryptedKey.getKey(EncryptedKey.java:354) at 
      com.sun.xml.ws.security.opt.impl.incoming.KeySelectorImpl.resolveDirectReference(KeySelectorImpl.java:540) at 
      com.sun.xml.ws.security.opt.impl.incoming.processor.SecurityTokenProcessor.processDirectReference(SecurityTokenProcessor.java:267) at 
      com.sun.xml.ws.security.opt.impl.incoming.processor.SecurityTokenProcessor.resolveReference(SecurityTokenProcessor.java:143) at 
      com.sun.xml.ws.security.opt.impl.incoming.processor.KeyInfoProcessor.processKeyInfo(KeyInfoProcessor.java:152) at 
      com.sun.xml.ws.security.opt.impl.incoming.processor.KeyInfoProcessor.getKey(KeyInfoProcessor.java:132) at 
      com.sun.xml.ws.security.opt.impl.incoming.EncryptedData.process(EncryptedData.java:156) at 
      com.sun.xml.ws.security.opt.impl.incoming.EncryptedData.&lt;init&gt;(EncryptedData.java:113) at 
      com.sun.xml.ws.security.opt.impl.incoming.SecurityRecipient.handleSecurityHeader(SecurityRecipient.java:458) at 
      com.sun.xml.ws.security.opt.impl.incoming.SecurityRecipient.cacheHeaders(SecurityRecipient.java:291) at 
      com.sun.xml.ws.security.opt.impl.incoming.SecurityRecipient.validateMessage(SecurityRecipient.java:241) at 
      com.sun.xml.wss.provider.wsit.WSITServerAuthContext.verifyInboundMessage(WSITServerAuthContext.java:588) at 
      com.sun.xml.wss.provider.wsit.WSITServerAuthContext.validateRequest(WSITServerAuthContext.java:361) at 
      com.sun.xml.wss.provider.wsit.WSITServerAuthContext.validateRequest(WSITServerAuthContext.java:264) at 
      com.sun.enterprise.security.webservices.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:173) at 
      com.sun.enterprise.security.webservices.CommonServerSecurityPipe.process(CommonServerSecurityPipe.java:144) at 
      com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:119) at 
      com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:961) at 
      com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:910) at 
      com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:873) at 
      com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:775) at 
      com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:386) at 
      com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:640) at 
      com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:263) at 
      com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:163) at 
      org.glassfish.webservices.Ejb3MessageDispatcher.handlePost(Ejb3MessageDispatcher.java:120) at 
      org.glassfish.webservices.Ejb3MessageDispatcher.invoke(Ejb3MessageDispatcher.java:91) at 
      org.glassfish.webservices.EjbWebServiceServlet.dispatchToEjbEndpoint(EjbWebServiceServlet.java:200) at 
      org.glassfish.webservices.EjbWebServiceServlet.service(EjbWebServiceServlet.java:131) at 
      javax.servlet.http.HttpServlet.service(HttpServlet.java:770) at 
      com.sun.grizzly.http.servlet.ServletAdapter$FilterChainImpl.doFilter(ServletAdapter.java:1059) at 
      com.sun.grizzly.http.servlet.ServletAdapter$FilterChainImpl.invokeFilterChain(ServletAdapter.java:999) at 
      com.sun.grizzly.http.servlet.ServletAdapter.doService(ServletAdapter.java:434) at 
      com.sun.grizzly.http.servlet.ServletAdapter.service(ServletAdapter.java:384) at 
      com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179) at 
      com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117) at 
      com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354) at 
      com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195) at 
      com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849) at 
      com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746) at 
      com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045) at 
      com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228) at 
      com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at 
  </code></pre>
  
  <p>This is my first time with webservice security and it's possible that i forgot a basic thing to add .</p>
  
  <p>Can you help me ?</p>
  
  <p>Thanks .</p>
  
  <p><strong>Edit:</strong>
  this the web service client xml :
  <em>deleted cause lack of space</em>
  <strong>and server side</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; 
  &lt;definitions 
      xmlns="http://schemas.xmlsoap.org/wsdl/" 
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
      xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="custom_ws" targetNamespace="http://ejb/" xmlns:tns="http://ejb/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:fi="http://java.sun.com/xml/ns/wsit/2006/09/policy/fastinfoset/service" xmlns:tcp="http://java.sun.com/xml/ns/wsit/2006/09/policy/soaptcp/service" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:sc="http://schemas.sun.com/2006/03/wss/server" xmlns:wspp="http://java.sun.com/xml/ns/wsit/policy" 
  &gt;
      &lt;message name="hmd"/&gt;
      &lt;message name="hmdResponse"/&gt;
      &lt;portType name="custom_ws"&gt;
          &lt;operation name="hmd"&gt;
              &lt;input message="tns:hmd"/&gt;
              &lt;output message="tns:hmdResponse"/&gt;
          &lt;/operation&gt;
      &lt;/portType&gt;
      &lt;binding name="custom_wsPortBinding" type="tns:custom_ws"&gt;
          &lt;wsp:PolicyReference URI="#custom_wsPortBindingPolicy"/&gt;
          &lt;operation name="hmd"&gt;
              &lt;input&gt;
                  &lt;wsp:PolicyReference URI="#custom_wsPortBinding_hmd_Input_Policy"/&gt;
              &lt;/input&gt;
              &lt;output&gt;
                  &lt;wsp:PolicyReference URI="#custom_wsPortBinding_hmd_Output_Policy"/&gt;
              &lt;/output&gt;
          &lt;/operation&gt;
      &lt;/binding&gt;
      &lt;service name="custom_ws"&gt;
          &lt;port name="custom_wsPort" binding="tns:custom_wsPortBinding"/&gt;
      &lt;/service&gt;
      &lt;wsp:Policy wsu:Id="custom_wsPortBindingPolicy"&gt;
          &lt;wsp:ExactlyOne&gt;
              &lt;wsp:All&gt;
                  &lt;wsam:Addressing wsp:Optional="false"/&gt;
                  &lt;sp:SymmetricBinding&gt;
                      &lt;wsp:Policy&gt;
                          &lt;sp:ProtectionToken&gt;
                              &lt;wsp:Policy&gt;
                                  &lt;sp:X509Token sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never"&gt;
                                      &lt;wsp:Policy&gt;
                                          &lt;sp:WssX509V3Token10/&gt;
                                          &lt;sp:RequireIssuerSerialReference/&gt;
                                      &lt;/wsp:Policy&gt;
                                  &lt;/sp:X509Token&gt;
                              &lt;/wsp:Policy&gt;
                          &lt;/sp:ProtectionToken&gt;
                          &lt;sp:Layout&gt;
                              &lt;wsp:Policy&gt;
                                  &lt;sp:Strict/&gt;
                              &lt;/wsp:Policy&gt;
                          &lt;/sp:Layout&gt;
                          &lt;sp:IncludeTimestamp/&gt;
                          &lt;sp:OnlySignEntireHeadersAndBody/&gt;
                          &lt;sp:AlgorithmSuite&gt;
                              &lt;wsp:Policy&gt;
                                  &lt;sp:Basic128/&gt;
                              &lt;/wsp:Policy&gt;
                          &lt;/sp:AlgorithmSuite&gt;
                      &lt;/wsp:Policy&gt;
                  &lt;/sp:SymmetricBinding&gt;
                  &lt;sp:Wss11&gt;
                      &lt;wsp:Policy&gt;
                          &lt;sp:MustSupportRefIssuerSerial/&gt;
                          &lt;sp:MustSupportRefThumbprint/&gt;
                          &lt;sp:MustSupportRefEncryptedKey/&gt;
                      &lt;/wsp:Policy&gt;
                  &lt;/sp:Wss11&gt;
                  &lt;sp:SignedEncryptedSupportingTokens&gt;
                      &lt;wsp:Policy&gt;
                          &lt;sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"&gt;
                              &lt;wsp:Policy&gt;
                                  &lt;sp:WssUsernameToken10/&gt;
                              &lt;/wsp:Policy&gt;
                          &lt;/sp:UsernameToken&gt;
                      &lt;/wsp:Policy&gt;
                  &lt;/sp:SignedEncryptedSupportingTokens&gt;
                  &lt;sc:KeyStore wspp:visibility="private" location="C:\glassfish312\glassfish\domains\domain1\config\keystore.jks" type="JKS" storepass="changeit" alias="xws-security-server"/&gt;
              &lt;/wsp:All&gt;
          &lt;/wsp:ExactlyOne&gt;
      &lt;/wsp:Policy&gt;
      &lt;wsp:Policy wsu:Id="custom_wsPortBinding_hmd_Input_Policy"&gt;
          &lt;wsp:ExactlyOne&gt;
              &lt;wsp:All&gt;
                  &lt;sp:EncryptedParts&gt;
                      &lt;sp:Body/&gt;
                  &lt;/sp:EncryptedParts&gt;
                  &lt;sp:SignedParts&gt;
                      &lt;sp:Body/&gt;
                      &lt;sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="AckRequested" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/&gt;
                      &lt;sp:Header Name="SequenceAcknowledgement" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/&gt;
                      &lt;sp:Header Name="Sequence" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/&gt;
                      &lt;sp:Header Name="CreateSequence" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/&gt;
                  &lt;/sp:SignedParts&gt;
              &lt;/wsp:All&gt;
          &lt;/wsp:ExactlyOne&gt;
      &lt;/wsp:Policy&gt;
      &lt;wsp:Policy wsu:Id="custom_wsPortBinding_hmd_Output_Policy"&gt;
          &lt;wsp:ExactlyOne&gt;
              &lt;wsp:All&gt;
                  &lt;sp:EncryptedParts&gt;
                      &lt;sp:Body/&gt;
                  &lt;/sp:EncryptedParts&gt;
                  &lt;sp:SignedParts&gt;
                      &lt;sp:Body/&gt;
                      &lt;sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing"/&gt;
                      &lt;sp:Header Name="AckRequested" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/&gt;
                      &lt;sp:Header Name="SequenceAcknowledgement" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/&gt;
                      &lt;sp:Header Name="Sequence" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/&gt;
                      &lt;sp:Header Name="CreateSequence" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702"/&gt;
                  &lt;/sp:SignedParts&gt;
              &lt;/wsp:All&gt;
          &lt;/wsp:ExactlyOne&gt;
      &lt;/wsp:Policy&gt;
  &lt;/definitions&gt;
  </code></pre>
  
  <p><strong>Edit 2</strong>
  I added part that seem missing to the client but its still not working , i get the same exception with a lot of warning  </p>
  
  <pre><code>  &lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2-b13 (branches/2.2-6964; 2012-01-09T18:04:18+0000) JAXWS-RI/2.2.6-promoted-b20 JAXWS/2.2 svn-revision#unknown. --&gt;&lt;!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2-b13 (branches/2.2-6964; 2012-01-09T18:04:18+0000) JAXWS-RI/2.2.6-promoted-b20 JAXWS/2.2 svn-revision#unknown. --&gt;
      &lt;definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ejb/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ejb/" name="custom_ws" xmlns:sc="http://schemas.sun.com/2006/03/wss/client" xmlns:wspp="http://java.sun.com/xml/ns/wsit/policy"&gt;
          &lt;types&gt;
              &lt;xsd:schema&gt;
                  &lt;xsd:import namespace="http://ejb/" schemaLocation="http://myurl.net:8080/custom_ws/custom_ws?xsd=1"/&gt;
              &lt;/xsd:schema&gt;
          &lt;/types&gt;
          &lt;message name="hmd"&gt;
              &lt;part name="parameters" element="tns:hmd"/&gt;
          &lt;/message&gt;
          &lt;message name="hmdResponse"&gt;
              &lt;part name="parameters" element="tns:hmdResponse"/&gt;
          &lt;/message&gt;
          &lt;portType name="custom_ws"&gt;
              &lt;operation name="hmd"&gt;
                  &lt;input wsam:Action="http://ejb/custom_ws/hmdRequest" message="tns:hmd"/&gt;
                  &lt;output wsam:Action="http://ejb/custom_ws/hmdResponse" message="tns:hmdResponse"/&gt;
              &lt;/operation&gt;
          &lt;/portType&gt;
          &lt;binding name="custom_wsPortBinding" type="tns:custom_ws"&gt;
              &lt;wsp:PolicyReference URI="#custom_wsPortBindingPolicy"/&gt;
              &lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/&gt;
              &lt;operation name="hmd"&gt;
                  &lt;soap:operation soapAction=""/&gt;
                  &lt;input&gt;
                      &lt;soap:body use="literal"/&gt;
                  &lt;/input&gt;
                  &lt;output&gt;
                      &lt;soap:body use="literal"/&gt;
                  &lt;/output&gt;
              &lt;/operation&gt;
          &lt;/binding&gt;
          &lt;service name="custom_ws"&gt;
              &lt;port name="custom_wsPort" binding="tns:custom_wsPortBinding"&gt;
                  &lt;soap:address location="http://my_url.net:8080/custom_ws/custom_ws"/&gt;
              &lt;/port&gt;
          &lt;/service&gt;
          &lt;wsp:Policy wsu:Id="custom_wsPortBindingPolicy"&gt;
              &lt;wsp:ExactlyOne&gt;
                  &lt;wsp:All&gt;
                     &lt;wsam:Addressing wsp:Optional="false"/&gt;
                      &lt;wsp:SymmetricBinding&gt;
                          &lt;wsp:Policy&gt;
                              &lt;wsp:ProtectionToken&gt;
                                  &lt;wsp:Policy&gt;
                                      &lt;wsp:X509Token wsp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never"&gt;
                                          &lt;wsp:Policy&gt;
                                              &lt;wsp:WssX509V3Token10/&gt;
                                              &lt;wsp:RequireIssuerSerialReference/&gt;
                                          &lt;/wsp:Policy&gt;
                                      &lt;/wsp:X509Token&gt;
                                  &lt;/wsp:Policy&gt;
                              &lt;/wsp:ProtectionToken&gt;
                              &lt;wsp:Layout&gt;
                                  &lt;wsp:Policy&gt;
                                      &lt;wsp:Strict/&gt;
                                  &lt;/wsp:Policy&gt;
                              &lt;/wsp:Layout&gt;
                              &lt;wsp:IncludeTimestamp/&gt;
                              &lt;wsp:OnlySignEntireHeadersAndBody/&gt;
                              &lt;wsp:AlgorithmSuite&gt;
                                  &lt;wsp:Policy&gt;
                                      &lt;wsp:Basic128/&gt;
                                  &lt;/wsp:Policy&gt;
                              &lt;/wsp:AlgorithmSuite&gt;
                          &lt;/wsp:Policy&gt;
                      &lt;/wsp:SymmetricBinding&gt;
                      &lt;wsp:Wss11&gt;
                          &lt;wsp:Policy&gt;
                              &lt;wsp:MustSupportRefIssuerSerial/&gt;
                              &lt;wsp:MustSupportRefThumbprint/&gt;
                              &lt;wsp:MustSupportRefEncryptedKey/&gt;
                          &lt;/wsp:Policy&gt;
                      &lt;/wsp:Wss11&gt;
                      &lt;wsp:SignedEncryptedSupportingTokens&gt;
                          &lt;wsp:Policy&gt;
                              &lt;wsp:UsernameToken wsp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"&gt;
                                  &lt;wsp:Policy&gt;
                                      &lt;wsp:WssUsernameToken10/&gt;
                                  &lt;/wsp:Policy&gt;
                              &lt;/wsp:UsernameToken&gt;
                          &lt;/wsp:Policy&gt;
                      &lt;/wsp:SignedEncryptedSupportingTokens&gt;
  
                      &lt;sc:TrustStore wspp:visibility="private" location="C:\glassfish312\glassfish\domains\domain1\config\cacerts.jks" type="JKS" storepass="changeit" peeralias="xws-security-server"/&gt;
                      &lt;sc:CallbackHandlerConfiguration wspp:visibility="private"&gt;
                          &lt;sc:CallbackHandler name="usernameHandler" classname="Gui.ociCallBackHandler"/&gt;
                          &lt;sc:CallbackHandler name="passwordHandler" classname="Gui.ociCallBackHandler"/&gt;
                      &lt;/sc:CallbackHandlerConfiguration&gt;
                  &lt;/wsp:All&gt;
              &lt;/wsp:ExactlyOne&gt;
          &lt;/wsp:Policy&gt;
      &lt;/definitions&gt;
  </code></pre>
  
  <p>warning
  <em>delted cause lack of space</em></p>
  
  <p><strong>Edit 3</strong>
  this the second try with the xml client file:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2-b13 (branches/2.2-6964; 2012-01-09T18:04:18+0000) JAXWS-RI/2.2.6-promoted-b20 JAXWS/2.2 svn-revision#unknown. --&gt;&lt;!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2-b13 (branches/2.2-6964; 2012-01-09T18:04:18+0000) JAXWS-RI/2.2.6-promoted-b20 JAXWS/2.2 svn-revision#unknown. --&gt;
  &lt;definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ejb/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ejb/" name="custom_ws" xmlns:sc="http://schemas.sun.com/2006/03/wss/client" xmlns:wspp="http://java.sun.com/xml/ns/wsit/policy"&gt;
      &lt;types&gt;
          &lt;xsd:schema&gt;
              &lt;xsd:import namespace="http://ejb/" schemaLocation="http://my_url.net:8080/custom_ws/custom_ws?xsd=1"/&gt;
          &lt;/xsd:schema&gt;
      &lt;/types&gt;
      &lt;message name="hmd" /&gt;
      &lt;message name="hmdResponse" /&gt;
      &lt;portType name="custom_ws"&gt;
          &lt;operation name="hmd"&gt;
              &lt;input message="tns:hmd" /&gt;
              &lt;output message="tns:hmdResponse" /&gt;
          &lt;/operation&gt;
      &lt;/portType&gt;
      &lt;binding name="custom_wsPortBinding" type="tns:custom_ws"&gt;
          &lt;wsp:PolicyReference URI="#custom_wsPortBindingPolicy" /&gt;
          &lt;operation name="hmd"&gt;
              &lt;input&gt;
                  &lt;wsp:PolicyReference URI="#custom_wsPortBinding_hmd_Input_Policy" /&gt;
              &lt;/input&gt;
              &lt;output&gt;
                  &lt;wsp:PolicyReference URI="#custom_wsPortBinding_hmd_Output_Policy" /&gt;
              &lt;/output&gt;
          &lt;/operation&gt;
      &lt;/binding&gt;
      &lt;service name="custom_ws"&gt;
          &lt;port name="custom_wsPort" binding="tns:custom_wsPortBinding" /&gt;
      &lt;/service&gt;
      &lt;wsp:Policy wsu:Id="custom_wsPortBindingPolicy"&gt;
          &lt;wsp:All&gt;
              &lt;wsp:Policy&gt;
                  &lt;wsp:ExactlyOne&gt;
                      &lt;wsp:All&gt;
                          &lt;sc:TrustStore wspp:visibility="private" location="C:\glassfish312\glassfish\domains\domain1\config\cacerts.jks" type="JKS" storepass="changeit" peeralias="xws-security-server" /&gt;
                          &lt;sc:CallbackHandlerConfiguration wspp:visibility="private"&gt;
                              &lt;sc:CallbackHandler name="usernameHandler" classname="Gui.ociCallBackHandler" /&gt;
                              &lt;sc:CallbackHandler name="passwordHandler" classname="Gui.ociCallBackHandler" /&gt;
                          &lt;/sc:CallbackHandlerConfiguration&gt;
                      &lt;/wsp:All&gt;
                  &lt;/wsp:ExactlyOne&gt;
              &lt;/wsp:Policy&gt;
              &lt;wsp:Policy&gt;
                  &lt;wsp:ExactlyOne&gt;
                      &lt;wsp:All&gt;
                          &lt;wsam:Addressing wsp:Optional="false" /&gt;
                          &lt;wsp:SymmetricBinding&gt;
                              &lt;wsp:Policy&gt;
                                  &lt;wsp:ProtectionToken&gt;
                                      &lt;wsp:Policy&gt;
                                          &lt;wsp:X509Token wsp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never"&gt;
                                              &lt;wsp:Policy&gt;
                                                  &lt;wsp:WssX509V3Token10 /&gt;
                                                  &lt;wsp:RequireIssuerSerialReference /&gt;
                                              &lt;/wsp:Policy&gt;
                                          &lt;/wsp:X509Token&gt;
                                      &lt;/wsp:Policy&gt;
                                  &lt;/wsp:ProtectionToken&gt;
                                  &lt;wsp:Layout&gt;
                                      &lt;wsp:Policy&gt;
                                          &lt;wsp:Strict /&gt;
                                      &lt;/wsp:Policy&gt;
                                  &lt;/wsp:Layout&gt;
                                  &lt;wsp:IncludeTimestamp /&gt;
                                  &lt;wsp:OnlySignEntireHeadersAndBody /&gt;
                                  &lt;wsp:AlgorithmSuite&gt;
                                      &lt;wsp:Policy&gt;
                                          &lt;wsp:Basic128 /&gt;
                                      &lt;/wsp:Policy&gt;
                                  &lt;/wsp:AlgorithmSuite&gt;
                              &lt;/wsp:Policy&gt;
                          &lt;/wsp:SymmetricBinding&gt;
                          &lt;wsp:Wss11&gt;
                              &lt;wsp:Policy&gt;
                                  &lt;wsp:MustSupportRefIssuerSerial /&gt;
                                  &lt;wsp:MustSupportRefThumbprint /&gt;
                                  &lt;wsp:MustSupportRefEncryptedKey /&gt;
                              &lt;/wsp:Policy&gt;
                          &lt;/wsp:Wss11&gt;
                          &lt;wsp:SignedEncryptedSupportingTokens&gt;
                              &lt;wsp:Policy&gt;
                                  &lt;wsp:UsernameToken wsp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"&gt;
                                      &lt;wsp:Policy&gt;
                                          &lt;wsp:WssUsernameToken10 /&gt;
                                      &lt;/wsp:Policy&gt;
                                  &lt;/wsp:UsernameToken&gt;
                              &lt;/wsp:Policy&gt;
                          &lt;/wsp:SignedEncryptedSupportingTokens&gt;
                          &lt;sc:KeyStore wspp:visibility="private" location="C:\glassfish312\glassfish\domains\domain1\config\keystore.jks" type="JKS" storepass="changeit" alias="xws-security-server" /&gt;
                      &lt;/wsp:All&gt;
                  &lt;/wsp:ExactlyOne&gt;
              &lt;/wsp:Policy&gt;
          &lt;/wsp:All&gt;
      &lt;/wsp:Policy&gt;
      &lt;wsp:Policy wsu:Id="custom_wsPortBinding_hmd_Input_Policy"&gt;
          &lt;wsp:ExactlyOne&gt;
              &lt;wsp:All&gt;
                  &lt;wsp:EncryptedParts&gt;
                      &lt;wsp:Body /&gt;
                  &lt;/wsp:EncryptedParts&gt;
                  &lt;wsp:SignedParts&gt;
                      &lt;wsp:Body /&gt;
                      &lt;wsp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="AckRequested" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702" /&gt;
                      &lt;wsp:Header Name="SequenceAcknowledgement" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702" /&gt;
                      &lt;wsp:Header Name="Sequence" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702" /&gt;
                      &lt;wsp:Header Name="CreateSequence" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702" /&gt;
                  &lt;/wsp:SignedParts&gt;
              &lt;/wsp:All&gt;
          &lt;/wsp:ExactlyOne&gt;
      &lt;/wsp:Policy&gt;
      &lt;wsp:Policy wsu:Id="custom_wsPortBinding_hmd_Output_Policy"&gt;
          &lt;wsp:ExactlyOne&gt;
              &lt;wsp:All&gt;
                  &lt;wsp:EncryptedParts&gt;
                      &lt;wsp:Body /&gt;
                  &lt;/wsp:EncryptedParts&gt;
                  &lt;wsp:SignedParts&gt;
                      &lt;wsp:Body /&gt;
                      &lt;wsp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing" /&gt;
                      &lt;wsp:Header Name="AckRequested" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702" /&gt;
                      &lt;wsp:Header Name="SequenceAcknowledgement" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702" /&gt;
                      &lt;wsp:Header Name="Sequence" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702" /&gt;
                      &lt;wsp:Header Name="CreateSequence" Namespace="http://docs.oasis-open.org/ws-rx/wsrm/200702" /&gt;
                  &lt;/wsp:SignedParts&gt;
              &lt;/wsp:All&gt;
          &lt;/wsp:ExactlyOne&gt;
      &lt;/wsp:Policy&gt;
  &lt;/definitions&gt;
  </code></pre>