如何使用SOAPEnvelope mime标头进行授权抢占?
SOAPEnvelope envelope = soapPart.getEnvelope();
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
mimeHeaders.addHeader("Content-type", "text/xml");
String authorization = new sun.misc.BASE64Encoder().encode(("user:pass").getBytes());
mimeHeaders.addHeader("Authorization", "Basic " + authorization);
答案 0 :(得分:0)
添加SOAPAction。我也面临同样的问题。在我的例子中,SOAPAction是操作名称。
MimeHeaders hd = soapMessage.getMimeHeaders();
hd.addHeader("SOAPAction", "getUserDetails");
String authorization = new sun.misc.BASE64Encoder().encode((username+":"+password).getBytes());
hd.addHeader("Authorization", "Basic " + authorization);