本文整理匯總了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);
}
}