简体   繁体   English

从消息响应中删除肥皂头

[英]Remove soap header from message response

How do I remove a 如何删除

<soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

node from a response message using Java (or web service configuration)? Java(或Web服务配置)从响应消息中获取节点?

I don't want to send back user name and password that is displayed in the header. 我不想发回标头中显示的用户名和密码。 Do I create a class to extend AbstractSoapInterceptor ? 我是否创建一个扩展AbstractSoapInterceptor的类?

I am using `cxf bus to configure my web service. 我正在使用`cxf总线来配置我的Web服务。

I don´t know how are you receiving the SOAP message, but If you can use (or instantiate) a javax.xml.soap.SOAPMessage you remove the header element or attribute that is bothering you: 我不知道您如何收到SOAP消息,但是,如果可以使用(或实例化) javax.xml.soap.SOAPMessage可以删除困扰您的header元素或属性:

// Removes the attribute "key" from the message header
message.getSOAPHeader().removeAttribute("key");

Anyway, reusing the same message sounds weird to me, perhaps you should consider creating a new fresh response message: 无论如何,重用相同的消息对我来说听起来很奇怪,也许您应该考虑创建新的新响应消息:

This statement create a brand new message: 该语句创建了一条全新的消息:

MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage(headers, in)

This one, from Mime headers and an inputstream: 这是来自Mime标头和输入流的:

MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage(headers, in)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM