This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes BEA/Weblogic and the fly likes Calling IIS web page from java (that is deployed in Weblogic) using Windows security Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Calling IIS web page from java (that is deployed in Weblogic) using Windows security" Watch "Calling IIS web page from java (that is deployed in Weblogic) using Windows security" New topic
Author

Calling IIS web page from java (that is deployed in Weblogic) using Windows security

get started
Greenhorn

Joined: Mar 10, 2009
Posts: 4
I am having trouble calling a IIS webpage, which enables Windows security. The code works fine in stand alone Java application, but not after deploying to weblogic.

Here is the sample code:

String auth = domain + "\\" + userName ":" + password;
String encodedAuth = new BASE64Encoder().encode(auth.getBytes());
URL url = new URL(serviceURL);
URLConnection yc = url.openConnection();
yc.setRequestProperty ("Authorization", "Basic " + encodedAuth);
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));

How do we specify windows authentication? Is it the correct way? Thanks,
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42367
    
  64
I don't think URLConnection supports Windows Security. If that's the same as NTLM, then check out HttpClient - it supports that.


Ping & DNS - my free Android networking tools app
get started
Greenhorn

Joined: Mar 10, 2009
Posts: 4
where do I specify domain name? this is only accepting username and password?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18711
    
    8

Try "domain\user" for your user name.
get started
Greenhorn

Joined: Mar 10, 2009
Posts: 4
HttpMethodBase method = null;
try {
HttpClient client = new HttpClient();
client.getState().setCredentials(AuthScope.ANY,
new NTCredentials(userName, pwd, host, domain) );
System.out.println(httpServiceURL);

method = new GetMethod(httpServiceURL);
method.setDoAuthentication( true );
int status = client.executeMethod(method);
System.out.println(status + "\n" + method.getResponseBodyAsString());
}

This works fine on stand alone java application, but when I deploy it to Weblogic.. it just hangs at GetMethod. No exception, nothing..
 
wood burning stoves
 
subject: Calling IIS web page from java (that is deployed in Weblogic) using Windows security