-
1. Re: SAAJ API & basic authentication (AS 4.0.4)
thomas.diesler Sep 14, 2006 1:04 PM (in response to mhae)Have a look at the test cases for basic auth
-
2. Re: SAAJ API & basic authentication (AS 4.0.4)
mhae Sep 14, 2006 6:27 PM (in response to mhae)Thanks. I couldn't find the test case you are talking about
but it is probably similar to this:
MessageFactory messagefactory = MessageFactory.newInstance();
SOAPMessage message = messagefactory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
// System.setProperty("http.basic.username", "webservice");
// System.setProperty("http.basic.password", "webservice");
StringBuffer buffer = new StringBuffer();
buffer.append("webservice");
buffer.append(":");
buffer.append("webservice");
String encoded = Base64.encodeBytes(buffer.toString().getBytes());
String authString = "Basic " + encoded;
message.getMimeHeaders().addHeader("Authorization", authString);