gillgates
asked on
Java equivalent to .NET's "System.Net.CredentialCache.DefaultCredentials"
Here is the code in C# which works
<Begin C# Code>
Webs.Webs x = new Webs.Webs();
x.PreAuthenticate = true;
x.Credentials = System.Net.CredentialCache .DefaultCr edentials;
x.Url = url + @"/_vti_bin/webs.asmx";
System.Xml.XmlNode n = x.GetWebCollection();
<End C# Code>
However I would like to access this SharePoint webservice from a java application. How do I replicate the "System.Net.CredentialCach e.DefaultC redentials " in java?
Here is my Java code but I get a "(401)Unauthorized" error which I also get in the .NET code if I don't do the "x.Credentials = System.Net.CredentialCache .DefaultCr edentials" call.
I used wsdl2java to bring the webservice into eclipse (http://wsdl2javawizard.sourceforge.net/)
<Begin Java Code>
try
{
_GetWebCollection parameters = new _GetWebCollection();
WebsLocator w = new WebsLocator();
WebsSoap ws = w.getWebsSoap();
ws.getWebCollection(parame ters);
}
catch (ServiceException e)
{
e.printStackTrace();
}
catch (RemoteException e)
{
e.printStackTrace();
}
<Begin C# Code>
Webs.Webs x = new Webs.Webs();
x.PreAuthenticate = true;
x.Credentials = System.Net.CredentialCache
x.Url = url + @"/_vti_bin/webs.asmx";
System.Xml.XmlNode n = x.GetWebCollection();
<End C# Code>
However I would like to access this SharePoint webservice from a java application. How do I replicate the "System.Net.CredentialCach
Here is my Java code but I get a "(401)Unauthorized" error which I also get in the .NET code if I don't do the "x.Credentials = System.Net.CredentialCache
I used wsdl2java to bring the webservice into eclipse (http://wsdl2javawizard.sourceforge.net/)
<Begin Java Code>
try
{
_GetWebCollection parameters = new _GetWebCollection();
WebsLocator w = new WebsLocator();
WebsSoap ws = w.getWebsSoap();
ws.getWebCollection(parame
}
catch (ServiceException e)
{
e.printStackTrace();
}
catch (RemoteException e)
{
e.printStackTrace();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.