Java的SAAJ基本身份验证 [英] Java SAAJ Basic Authentication
问题描述
我有一个基本的SOAP服务端点,其实SAP ECC,presenting的服务。我测试了利用SOAPUI 4.5服务,它使用HTTP验证,preemptive由事物的容貌工程确定。我看到出站授权:基本BASE64,服务作适当的反应。
I have a basic SOAP service endpoint, actually SAP ECC, presenting a service. I have tested the service using SOAPUI 4.5, and it works ok using HTTP Auth, preemptive by the looks of things. I see an outbound "Authorization:Basic BASE64" and the service responds appropriately.
我现在想卷进这个Java的。我以为我会采取用SAAJ方式:
I am now trying to roll this into Java. I thought that I would take a SAAJ approach with:
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnectionFactory.createConnection();
String url = "http://SAPSERVER:8006/sap/bc/srt/rfc/sap/z_lookup_generic_prototype/300/z_user/z_user_binding";
SOAPMessage message = messageFactory.createMessage();
SOAPMessage response = connection.call(message, url);
但我不能找到一种方法,在添加该HTTP认证我相信,SAAJ提供了控制SOAP消息的手段,但我怎么加认证?是否有任何替代品值得考虑的?
But I cannot find a way to add the HTTP authentication in. I believe that SAAJ provides the means to control the SOAP message, but how do I add authentication in? Are there any alternatives worth considering?
推荐答案
在此页:<一href=\"https://www.$c$cranch.com/how-to/java/WebServicesHowTo\">https://www.$c$cranch.com/how-to/java/WebServicesHowTo
SOAPMessage message = ...
String authorization = new sun.misc.BASE64Encoder().encode((username+":"+password).getBytes());
MimeHeaders hd = message.getMimeHeaders();
hd.addHeader("Authorization", "Basic " + authorization);
这篇关于Java的SAAJ基本身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!