title: Axis 2 and Rampart- why does service return wsse:Security header in request?
body: <p>I'm connecting to a secure service.</p>
  
  <p>I have a SOAP UI project configured to use a jks file to provide the certificate, along with appropriate security settings to allow me to get a valid response.</p>
  
  <p>I've have used AXIS 2 and Rampart to create a SOAP request from a JAVA project.
  Using TCPMon I've managed to grab the SOAP request.</p>
  
  <p>When the request runs in the JAVA project, I just get the response:</p>
  
  <p><em>org.apache.axis2.AxisFault: Missing wsse:Security header in request</em></p>
  
  <p>but if I take the same request, captured in TCPMon and put it in a SOAP UI project, I get a response successfully.</p>
  
  <p>Anyone got any ideas?</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;  &lt;soapenv:Header&gt;  
  &lt;wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"  
  soapenv:mustUnderstand="1"&gt;  
    &lt;wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"  
    wsu:Id="Timestamp-1"&gt;  
      &lt;wsu:Created&gt;2012-06-01T15:09:12.520Z&lt;/wsu:Created&gt;  
      &lt;wsu:Expires&gt;2012-06-01T15:14:12.520Z&lt;/wsu:Expires&gt;  
    &lt;/wsu:Timestamp&gt;  
    &lt;wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"  
    EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"  
    ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"  
    wsu:Id="CertId-ECDB0E....01"&gt;  
    MIID4DCCA0mgAwIBAgIBFjAN....&lt;/wsse:BinarySecurityToken&gt;  
    &lt;ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"  
    Id="Signature-2"&gt;  
      &lt;ds:SignedInfo&gt;  
        &lt;ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /&gt;  
        &lt;ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /&gt;  
        &lt;ds:Reference URI="#Id-15..93"&gt;  
          &lt;ds:Transforms&gt;  
            &lt;ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /&gt;  
          &lt;/ds:Transforms&gt;  
          &lt;ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /&gt;  
          &lt;ds:DigestValue&gt;  
          3wgvhJ8SI2soC..IA=&lt;/ds:DigestValue&gt;  
        &lt;/ds:Reference&gt;  
        &lt;ds:Reference URI="#Timestamp-1"&gt;  
          &lt;ds:Transforms&gt;  
            &lt;ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /&gt;  
          &lt;/ds:Transforms&gt;  
          &lt;ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /&gt;  
          &lt;ds:DigestValue&gt;  
          VlzDT69YEl..qTlbj0=&lt;/ds:DigestValue&gt;  
        &lt;/ds:Reference&gt;  
      &lt;/ds:SignedInfo&gt;  
      &lt;ds:SignatureValue&gt;  
      ZCRypw/..=&lt;/ds:SignatureValue&gt;  
      &lt;ds:KeyInfo Id="KeyId-ECD..2"&gt;  
        &lt;wsse:SecurityTokenReference xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"  
        wsu:Id="STRId-ECDB0E6..6193"&gt;  
          &lt;wsse:Reference URI="#CertId-ECDB0E..01"  
          ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" /&gt;  
        &lt;/wsse:SecurityTokenReference&gt;  
      &lt;/ds:KeyInfo&gt;  
    &lt;/ds:Signature&gt;  
  &lt;/wsse:Security&gt;&lt;/soapenv:Header&gt;&lt;soapenv:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Id-15..3"&gt;&lt;ns2:ProductSearchV2Request xmlns:ns2="http://product.webservice.sxc.com"&gt;   
    &lt;ns2:Strength&gt;900&lt;/ns2:Strength&gt;  
    &lt;ns2:MaximumResultSetInd&gt;true&lt;/ns2:MaximumResultSetInd&gt;  
    &lt;ns2:MaximumResultSet&gt;100&lt;/ns2:MaximumResultSet&gt;  
  &lt;/ns2:ProductSearchV2Request&gt;  
  </code></pre>
  
  <p><br>
  </p>
  
  <p>This is the WS-POLICY document that I'm using:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;  
  &lt;!--  
   !  
   ! Copyright 2006 The Apache Software Foundation.  
   !  
   ! Licensed under the Apache License, Version 2.0 (the "License");  
   ! you may not use this file except in compliance with the License.  
   ! You may obtain a copy of the License at  
   !  
   !      http://www.apache.org/licenses/LICENSE-2.0  
   !  
   ! Unless required by applicable law or agreed to in writing, software  
   ! distributed under the License is distributed on an "AS IS" BASIS,  
   ! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
   ! See the License for the specific language governing permissions and  
   ! limitations under the License.  
   !--&gt;  
  &lt;wsp:Policy wsu:Id="SigOnly"  
              xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"  
              xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"&gt;  
      &lt;wsp:ExactlyOne&gt;  
          &lt;wsp:All&gt;  
              &lt;sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;  
                  &lt;wsp:Policy&gt;  
                      &lt;sp:InitiatorToken&gt;  
                          &lt;wsp:Policy&gt;  
                              &lt;sp:X509Token  
                                      sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"&gt;  
                                  &lt;wsp:Policy&gt;  
                                      &lt;sp:RequireThumbprintReference/&gt;  
                                      &lt;sp:WssX509V3Token10/&gt;  
                                  &lt;/wsp:Policy&gt;  
                              &lt;/sp:X509Token&gt;  
                          &lt;/wsp:Policy&gt;  
                      &lt;/sp:InitiatorToken&gt;  
                      &lt;sp:RecipientToken&gt;  
                          &lt;wsp:Policy&gt;  
                              &lt;sp:X509Token  
                                      sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never"&gt;  
                                  &lt;wsp:Policy&gt;  
                                      &lt;sp:RequireThumbprintReference/&gt;  
                                      &lt;sp:WssX509V3Token10/&gt;  
                                  &lt;/wsp:Policy&gt;  
                              &lt;/sp:X509Token&gt;  
                          &lt;/wsp:Policy&gt;  
                      &lt;/sp:RecipientToken&gt;  
                      &lt;sp:AlgorithmSuite&gt;  
                          &lt;wsp:Policy&gt;  
                              &lt;sp:TripleDesRsa15/&gt;  
                          &lt;/wsp:Policy&gt;  
                      &lt;/sp:AlgorithmSuite&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;/wsp:Policy&gt;  
              &lt;/sp:AsymmetricBinding&gt;  
              &lt;sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;  
                  &lt;wsp:Policy&gt;  
                      &lt;sp:MustSupportRefKeyIdentifier/&gt;  
                      &lt;sp:MustSupportRefIssuerSerial/&gt;  
                  &lt;/wsp:Policy&gt;  
              &lt;/sp:Wss10&gt;  
              &lt;sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;  
                  &lt;sp:Body/&gt;  
              &lt;/sp:SignedParts&gt;  
              &lt;ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"&gt;  
                  &lt;ramp:user&gt;ctr&lt;/ramp:user&gt;  
                  &lt;ramp:encryptionUser&gt;ctr&lt;/ramp:encryptionUser&gt;  
                  &lt;ramp:passwordCallbackClass&gt;com.gtnet.rampart.PWCBHandler  
                  &lt;/ramp:passwordCallbackClass&gt;  
  
                  &lt;ramp:signatureCrypto&gt;  
                      &lt;ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin"&gt;  
                          &lt;ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type"&gt;JKS&lt;/ramp:property&gt;  
                          &lt;ramp:property name="org.apache.ws.security.crypto.merlin.file"&gt;build\resources\qa.jks&lt;/ramp:property&gt;  
                          &lt;ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password"&gt;123123&lt;/ramp:property&gt;  
                      &lt;/ramp:crypto&gt;  
                  &lt;/ramp:signatureCrypto&gt;  
              &lt;/ramp:RampartConfig&gt;  
  
          &lt;/wsp:All&gt;  
      &lt;/wsp:ExactlyOne&gt;  
  &lt;/wsp:Policy&gt;  
  </code></pre>
  
  <p>Thanks
  Alan</p>