SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

the code are as follows:

private static EndpointReference targetEPR = new EndpointReference(  
ServiceClient sender = new ServiceClient();

List authSchema = new ArrayList(); 
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
List authPrefs = new ArrayList(1); 
      .setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth); 
      .setProperty (HTTPConstants.HTTP_PROTOCOL_VERSION, HTTPConstants.HEADER_PROTOCOL_10);

OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("", "");
OMElement data = fac.createOMElement("CheckOutFile", omNs);
OMElement inner = fac.createOMElement("pageUrl", omNs);
inner.setText("http://sharepoint01/Shared Documents/fpga.doc");
OMElement inner1 = fac.createOMElement("checkoutToLocal", omNs);
inner.setText("true"); OMElement inner2 = fac.createOMElement("lastmodified", omNs);
inner.setText(""); data.addChild(inner); data.addChild(inner1); data.addChild(inner2);

OMElement result = sender.sendReceive;

and the error code is

Exception in thread "main" org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized at org.apache.axis2.transport.http.HTTPSender.handleResponse( at org.apache.axis2.transport.http.HTTPSender.sendViaPost( at org.apache.axis2.transport.http.HTTPSender.send( at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons( at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke( at org.apache.axis2.engine.AxisEngine.send( at org.apache.axis2.description.OutInAxisOperationClient.send( at org.apache.axis2.description.OutInAxisOperationClient.executeImpl( at org.apache.axis2.client.OperationClient.execute( at org.apache.axis2.client.ServiceClient.sendReceive( at org.apache.axis2.client.ServiceClient.sendReceive( at test01.getResult( at test01.main(

share|improve this question
Take a look in the IIS logs, to see what kind of 401 is thrown (401.1, 401.2, ...). This is maybe a server configuration issue. Also, please explains what kind of authentication you have set up on the SharePoint farm, especially if you have setup the web application to use claims authentication – Steve B Dec 12 '12 at 13:47

Not a Java expert but you are not setting the domain, username and password when making the connection. TherefOre the request is sent anonymously and is not authenticated and you get a 401 error

share|improve this answer
Many thanks for you quick reply. So you mean the setting in my code is invalid ? And do you know how to setting the domain, username and password exactly? And could you give me some example code? – user10510 Sep 5 '12 at 1:46
I believe in Java you have to ask for the credentials. In '.net you can use a default set which users the current users login details. I found this post… I can see from your code that you have calls to setusername() setdomain and setpassword() I would try populating those to get it working and then look at how you could get the credentials from the user in a nice way. – Simon Doy Sep 5 '12 at 22:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.