Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve failure of JAX_WS web service invocation "MustUnderstand headers are not understood"?

I'm using SOAPUI tool to access JAX-WS web services deployed in Weblogic 10.3.2

Request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.pc3.polk.com/">
    <soapenv:Header>
        <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <wsu:Timestamp wsu:Id="Timestamp-1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsu:Created>2010-12-03T21:10:43Z</wsu:Created>
            <wsu:Expires>2010-12-03T21:44:03Z</wsu:Expires>
        </wsu:Timestamp>
        <wsu:Timestamp wsu:Id="Timestamp-60" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsu:Created>2010-12-03T20:10:39Z</wsu:Created>
            <wsu:Expires>2010-12-03T20:43:59Z</wsu:Expires>
        </wsu:Timestamp>
        <wsse:UsernameToken wsu:Id="UsernameToken-59" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:Username>rwerqre</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">ewrqwrwerqer</wsse:Password>
            <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">Nmw0ksmiOX+hkiSoWb2Rjg==</wsse:Nonce>
            <wsu:Created>2010-12-03T20:10:39.649Z</wsu:Created>
        </wsse:UsernameToken>
    </wsse:Security>
    </soapenv:Header>
   <soapenv:Body>
      <ws:getMetadata/>
   </soapenv:Body>
</soapenv:Envelope>

Response:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <SOAP-ENV:Fault xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
         <faultcode>SOAP-ENV:MustUnderstand</faultcode>
         <faultstring>MustUnderstand headers:[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security] are not understood</faultstring>
      </SOAP-ENV:Fault>
   </S:Body>
</S:Envelope>
like image 647
Roman Kagan Avatar asked Dec 06 '10 16:12

Roman Kagan


2 Answers

You can configure a dummy SOAPHandler for {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security that would mark this header as 'understood'.

Or you could change the SOAP request (on the caller side) to set mustUnderstand="0" in the security header.

Example security SOAP header with mustUnderstand="0":

<S:Header xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <wsse:Security S:mustUnderstand="0" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <wsse:UsernameToken>
         <wsse:Username>USERNAME</wsse:Username>
         <wsse:Password wsse:Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>
      </wsse:UsernameToken>
   </wsse:Security>
</S:Header>
like image 175
rustyx Avatar answered Oct 10 '22 17:10

rustyx


Issue is with the Handlers. You need to add following in handler implementation

public Set<QName> getHeaders() {
    final QName securityHeader = new QName(
        "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
        "Security",
        "wsse");

    final HashSet headers = new HashSet();
    headers.add(securityHeader);
    return headers;
}
like image 30
mrigank sharma Avatar answered Oct 10 '22 18:10

mrigank sharma