我試圖運行在主我的java類以下。代碼使用存根首先進行身份驗證,然後在Microsoft SharePoint站點中恢復列表的集合。調用的SharePoint Web服務使用Axis2客戶端進行身份驗證
的代碼如下:
ListsStub stub = new ListsStub();
HttpTransportProperties.Authenticator auth = new HttpT
ransportProperties.Authenticator();
auth.setUsername(username);
auth.setPassword(pw);
auth.setDomain(domain);
auth.setHost(host);
List schemes = new ArrayList(1);
schemes.add(AuthPolicy.NTLM);
auth.setAuthSchemes (schemes);
stub._getServiceClient().getOptions().setProperty(
org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,
auth);
stub._getServiceClient().getOptions().setProperty (HTTPConstants.HTTP_PROTOCOL_VERSION,
HTTPConstants.HEADER_PROTOCOL_10);
//stub._getServiceClient().getOptions().setProperty (HTTPConstants.PROXY, proxy);
String liste = "sharepointlist";
String document2ID;
ListsStub.GetListCollection req = new ListsStub.GetListCollection();
ListsStub.GetListCollectionResponse res = null;
try {
res = stub.getListCollection(req);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我得到一個401,表示我的登錄信息不正確:
org.apache.axis2.AxisFault:傳輸錯誤:401錯誤:未經授權 在組織.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:310) 在org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:200) 在org.apache.axis2.transport .http.HTTPSender.send(HTTPSender.java:76) 在org.apache.axis2.transport.htt p.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400) 在org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225) 在org.apache.axis2.engine.AxisEngine.send(AxisEngine。的java:435) 在org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402) 在org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) 在org.apache。 axis2.client.OperationClient.execute(OperationClient.java:165) at org.apache.axis2.axis2userguide.ListsStub.getListCollection(ListsStub.java:1936) at gov.nasa.jpl.spconnect.MainKickOff.main(MainKickOff。的java:73)
有誰知道我爲什麼會得到這個?