You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Mona Yazbeck <mo...@hec.ca> on 2006/05/24 22:04:30 UTC

(401) Unauthorized

Hello, 

I am having trouble connecting to a .NET web service. It is a web service that comes with Windows SharePoint Services (WSS), it has an authentication part.

I get the error (401) Unauthorized (complete error below). I understand that I have a problem with my authentication, but I don't know how to fix it, please help!

Thanks!

-------------
Here's my code

Service service = new Service();
Call call = (Call)service.createCall();

call.setTargetEndpointAddress(new java.net.URL("http://myServer/_vti_bin/Lists.asmx"));
call.setOperation("GetListCollection");
call.setSOAPActionURI("http://schemas.microsoft.com/sharepoint/soap/GetListCollection");
call.setUseSOAPAction(true);

call.setUsername("username");
call.setPassword("password");
call.setProperty(WsseClientHandler.PASSWORD_OPTION, WsseClientHandler.PASSWORD_DIGEST_WITH_NONCE);

call.setClientHandlers(new WsseClientHandler(), null);
String ret = ((String)call.invoke(new Object[] {}));

-------------------

AxisFault
faultCode: {http://xml.apache.org/axis/}HTTP
faultSubcode: 
faultString: (401)Unauthorized
faultActor: 
faultNode: 
faultDetail: 
{}:return code:  401
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;You are not authorized to view this
page&lt;/TITLE&gt;
&lt;META HTTP-EQUIV=&quot;Content-Type&quot; Content=&quot;text/html; charset=Windows-1252&quot;&gt;
&lt;STYLE type=&quot;text/css&quot;&gt;
  BODY { font: 8pt/12pt verdana }
  H1 { font: 13pt/15pt verdana }
  H2 { font: 8pt/12pt verdana }
  A:link { color: red }
  A:visited { color: maroon }
&lt;/STYLE&gt;
&lt;/HEAD&gt;&lt;BODY&gt;&lt;TABLE width=500 border=0 cellspacing=10&gt;&lt;TR&gt;&lt;TD&gt;

&lt;h1&gt;You are not authorized to view this page&lt;/h1&gt;
You do not have permission to view this directory or page using the credentials
that you supplied because your Web browser is sending a WWW-Authenticate
header field that the Web server is not configured to accept.
&lt;hr&gt;
&lt;p&gt;Please try the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Contact the Web site administrator if you believe you should
be able to view this directory or page.&lt;/li&gt;
&lt;li&gt;Click the &lt;a href=&quot;javascript:location.reload()&quot;&gt;Refresh&lt;/a&gt;
button to try again with different credentials.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;HTTP Error 401.2 - Unauthorized: Access is denied due to server
configuration.&lt;br&gt;Internet Information Services (IIS)&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;Technical Information (for support personnel)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to &lt;a href=&quot;http://go.microsoft.com/fwlink/?linkid=8180&quot;&gt;Microsoft
Product Support Services&lt;/a&gt; and perform a title search for the words
&lt;b&gt;HTTP&lt;/b&gt; and &lt;b&gt;401&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Open &lt;b&gt;IIS Help&lt;/b&gt;, which is accessible in IIS
Manager (inetmgr),
and search for topics titled &lt;b&gt;About Security&lt;/b&gt;, &lt;b&gt;Authentication&lt;/b&gt;, and &lt;b&gt;About Custom Error Messages&lt;/b&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;

{http://xml.apache.org/axis/}HttpErrorCode:401

(401)Unauthorized
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at _testclient__jsp._jspService(/axis/TestClient.jsp:72)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:506)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:253)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:171)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:534)

Re: (401) Unauthorized

Posted by Mona Yazbeck <mo...@hec.ca>.
When I extract this line from my code 
(call.setProperty(WsseClientHandler.PASSWORD_OPTION, WsseClientHandler.PASSWORD_DIGEST_WITH_NONCE);)

I have a Server.userException error...

AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: java.lang.NullPointerException
 faultActor: 
 faultNode: 
 faultDetail: 
	{http://xml.apache.org/axis/}stackTrace:java.lang.NullPointerException
	at net.vitale.filippo.axis.handlers.WsseClientHandler.createUsernameToken(WsseClientHandler.java:125)
	at net.vitale.filippo.axis.handlers.WsseClientHandler.invoke(WsseClientHandler.java:99)
	at org.apache.axis.client.AxisClient.invoke(AxisClient.java:121)
	at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
	at org.apache.axis.client.Call.invoke(Call.java:2767)
	at org.apache.axis.client.Call.invoke(Call.java:2443)
	at org.apache.axis.client.Call.invoke(Call.java:2366)
	at org.apache.axis.client.Call.invoke(Call.java:1812)
	at _testclient__jsp._jspService(/axis/TestClient.jsp:74)
	at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
	at com.caucho.jsp.Page.subservice(Page.java:506)
	at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
	at com.caucho.server.http.Invocation.service(Invocation.java:315)
	at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
	at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:253)
	at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:170)
	at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
	at java.lang.Thread.run(Thread.java:534)

	{http://xml.apache.org/axis/}hostname:HEC-5170

java.lang.NullPointerException
	at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
	at net.vitale.filippo.axis.handlers.WsseClientHandler.invoke(WsseClientHandler.java:106)
	at org.apache.axis.client.AxisClient.invoke(AxisClient.java:121)
	at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
	at org.apache.axis.client.Call.invoke(Call.java:2767)
	at org.apache.axis.client.Call.invoke(Call.java:2443)
	at org.apache.axis.client.Call.invoke(Call.java:2366)
	at org.apache.axis.client.Call.invoke(Call.java:1812)
	at _testclient__jsp._jspService(/axis/TestClient.jsp:74)
	at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
	at com.caucho.jsp.Page.subservice(Page.java:506)
	at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
	at com.caucho.server.http.Invocation.service(Invocation.java:315)
	at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
	at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:253)
	at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:170)
	at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
	at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.NullPointerException
	at net.vitale.filippo.axis.handlers.WsseClientHandler.createUsernameToken(WsseClientHandler.java:125)
	at net.vitale.filippo.axis.handlers.WsseClientHandler.invoke(WsseClientHandler.java:99)
	... 16 more
----- Message d'origine ----- 
  De : Mona Yazbeck 
  À : axis-user@ws.apache.org 
  Envoyé : 24 mai 2006 16:04
  Objet : (401) Unauthorized


  Hello, 

  I am having trouble connecting to a .NET web service. It is a web service that comes with Windows SharePoint Services (WSS), it has an authentication part.

  I get the error (401) Unauthorized (complete error below). I understand that I have a problem with my authentication, but I don't know how to fix it, please help!

  Thanks!

  -------------
  Here's my code

  Service service = new Service();
  Call call = (Call)service.createCall();

  call.setTargetEndpointAddress(new java.net.URL("http://myServer/_vti_bin/Lists.asmx"));
  call.setOperation("GetListCollection");
  call.setSOAPActionURI("http://schemas.microsoft.com/sharepoint/soap/GetListCollection");
  call.setUseSOAPAction(true);

  call.setUsername("username");
  call.setPassword("password");
  call.setProperty(WsseClientHandler.PASSWORD_OPTION, WsseClientHandler.PASSWORD_DIGEST_WITH_NONCE);

  call.setClientHandlers(new WsseClientHandler(), null);
  String ret = ((String)call.invoke(new Object[] {}));

  -------------------

  AxisFault
  faultCode: {http://xml.apache.org/axis/}HTTP
  faultSubcode: 
  faultString: (401)Unauthorized
  faultActor: 
  faultNode: 
  faultDetail: 
  {}:return code:  401
  &lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
  &lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;You are not authorized to view this
  page&lt;/TITLE&gt;
  &lt;META HTTP-EQUIV=&quot;Content-Type&quot; Content=&quot;text/html; charset=Windows-1252&quot;&gt;
  &lt;STYLE type=&quot;text/css&quot;&gt;
    BODY { font: 8pt/12pt verdana }
    H1 { font: 13pt/15pt verdana }
    H2 { font: 8pt/12pt verdana }
    A:link { color: red }
    A:visited { color: maroon }
  &lt;/STYLE&gt;
  &lt;/HEAD&gt;&lt;BODY&gt;&lt;TABLE width=500 border=0 cellspacing=10&gt;&lt;TR&gt;&lt;TD&gt;

  &lt;h1&gt;You are not authorized to view this page&lt;/h1&gt;
  You do not have permission to view this directory or page using the credentials
  that you supplied because your Web browser is sending a WWW-Authenticate
  header field that the Web server is not configured to accept.
  &lt;hr&gt;
  &lt;p&gt;Please try the following:&lt;/p&gt;
  &lt;ul&gt;
  &lt;li&gt;Contact the Web site administrator if you believe you should
  be able to view this directory or page.&lt;/li&gt;
  &lt;li&gt;Click the &lt;a href=&quot;javascript:location.reload()&quot;&gt;Refresh&lt;/a&gt;
  button to try again with different credentials.&lt;/li&gt;
  &lt;/ul&gt;
  &lt;h2&gt;HTTP Error 401.2 - Unauthorized: Access is denied due to server
  configuration.&lt;br&gt;Internet Information Services (IIS)&lt;/h2&gt;
  &lt;hr&gt;
  &lt;p&gt;Technical Information (for support personnel)&lt;/p&gt;
  &lt;ul&gt;
  &lt;li&gt;Go to &lt;a href=&quot;http://go.microsoft.com/fwlink/?linkid=8180&quot;&gt;Microsoft
  Product Support Services&lt;/a&gt; and perform a title search for the words
  &lt;b&gt;HTTP&lt;/b&gt; and &lt;b&gt;401&lt;/b&gt;.&lt;/li&gt;
  &lt;li&gt;Open &lt;b&gt;IIS Help&lt;/b&gt;, which is accessible in IIS
  Manager (inetmgr),
  and search for topics titled &lt;b&gt;About Security&lt;/b&gt;, &lt;b&gt;Authentication&lt;/b&gt;, and &lt;b&gt;About Custom Error Messages&lt;/b&gt;.&lt;/li&gt;
  &lt;/ul&gt;

  &lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;

  {http://xml.apache.org/axis/}HttpErrorCode:401

  (401)Unauthorized
  at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
  at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
  at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
  at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
  at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
  at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
  at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
  at org.apache.axis.client.Call.invoke(Call.java:2767)
  at org.apache.axis.client.Call.invoke(Call.java:2443)
  at org.apache.axis.client.Call.invoke(Call.java:2366)
  at org.apache.axis.client.Call.invoke(Call.java:1812)
  at _testclient__jsp._jspService(/axis/TestClient.jsp:72)
  at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
  at com.caucho.jsp.Page.subservice(Page.java:506)
  at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
  at com.caucho.server.http.Invocation.service(Invocation.java:315)
  at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
  at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:253)
  at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:171)
  at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
  at java.lang.Thread.run(Thread.java:534)