本文整理汇总了Java中javax.xml.soap.SOAPMessage.getMimeHeaders方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPMessage.getMimeHeaders方法的具体用法?Java SOAPMessage.getMimeHeaders怎么用?Java SOAPMessage.getMimeHeaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.soap.SOAPMessage
的用法示例。
在下文中一共展示了SOAPMessage.getMimeHeaders方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResponse
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
@Override
protected Packet getResponse(Packet request, @Nullable SOAPMessage returnValue, WSDLPort port, WSBinding binding) {
Packet response = super.getResponse(request, returnValue, port, binding);
// Populate SOAPMessage's transport headers
if (returnValue != null && response.supports(Packet.OUTBOUND_TRANSPORT_HEADERS)) {
MimeHeaders hdrs = returnValue.getMimeHeaders();
Map<String, List<String>> headers = new HashMap<String, List<String>>();
Iterator i = hdrs.getAllHeaders();
while(i.hasNext()) {
MimeHeader header = (MimeHeader)i.next();
if(header.getName().equalsIgnoreCase("SOAPAction"))
// SAAJ sets this header automatically, but it interferes with the correct operation of JAX-WS.
// so ignore this header.
continue;
List<String> list = headers.get(header.getName());
if (list == null) {
list = new ArrayList<String>();
headers.put(header.getName(), list);
}
list.add(header.getValue());
}
response.put(Packet.OUTBOUND_TRANSPORT_HEADERS, headers);
}
return response;
}
示例2: addAuthorization
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
/**
* Adds 'Authorization' to the input message's header, provided the userId property has been defined.
* @param message the SOAP message.
*/
protected void addAuthorization(SOAPMessage message) {
if (getUserId() != null) {
StringBuilder userPwd = new StringBuilder(getUserId());
if (getPassword() != null) {
userPwd.append(':').append(getPassword());
}
// @todo: Do not use SUN's class. Find an alternative or write our own function
// @todo: Change the password property from String to byte[]
String authorization = new sun.misc.BASE64Encoder().encode(userPwd.toString().getBytes());
MimeHeaders headers = message.getMimeHeaders();
headers.addHeader("Authorization", "Basic " + authorization);
}
}