如何使用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);
最佳答案
添加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);
关于java - Java Soap客户端的抢占式授权,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20459297/