SOAP请求消息标头无法记录

时间:2019-07-18 09:09:45

标签: xml spring-boot soap soapheader soaphandler

我有一个工作中的肥皂客户端代码发送请求并获得响应。但是,当我尝试使用肥皂处理程序将请求记录到数据库时,标题部分没有出现,并且出现以下消息。

<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>

我的消息处理程序是

@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;
    }

我希望在数据库中看到一个完整的请求标头,例如;

<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>

0 个答案:

没有答案