Ahmet Orhan
Ahmet Orhan

Reputation: 346

SOAP request message header is can not logging

I have a working soap client code sends requests and gets response. But when I tried to log my requests with soap handler to DataBase, the header parts does not appears and I get the following message.

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/> //missing part
    <S:Body>
        "bla bla bla"
    </S:Body>
</S:Envelope>

My message handler is,

@Override
    public boolean handleMessage(SOAPMessageContext context) {
        Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
        SOAPMessage message = context.getMessage();     
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            message.writeTo(out);
        } catch (SOAPException | IOException e) {
            e.printStackTrace();
        }
        if (isRequest) {
            MyLogService.saveResponse(logRefNo, "", "", "", "", "", "", "", out.toByteArray());
        } else {
            MyLogService.saveResponse(logRefNo, "", "", out.toByteArray());
        }
        return true;
    }

I am expecting to see in DB a full request header like;

<s:Header>
     <o:Security s:mustUnderstand=1 xmlns:o=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd>
            <o:UsernameToken u:Id=uuid-0df61a7941-1436-41157-8368-d1c85c01d6cac31-1>
                <o:Username>?</o:Username>
                <o:Password Type=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText>?</o:Password>
            </o:UsernameToken>
        </o:Security>
</s:Header>

Upvotes: 0

Views: 455

Answers (0)

Related Questions