使用 Axis2 客户端身份验证调用 SharePoint Web 服务
我正在尝试在我的 java 类的 main 中运行以下内容。该代码使用存根首先进行身份验证,然后带回 Microsoft Sharepoint 站点中的列表集合。
代码如下:
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: Transport error: 401 Error: Unauthorized 在 org.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.http.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) 在 org.apache.axis2.axis2userguide.ListsStub.getListCollection(ListsStub.java:1936) 在 gov.nasa.jpl.spconnect.MainKickOff.main(MainKickOff.java:73)
有谁知道为什么我会得到这个?
I'm trying to run the following in the main of my java class. The code uses the stub to first authenticate and then bring back the collection of lists in a microsoft sharepoint site.
The code is as follows:
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();
}
I get a 401 that indicates my login is incorrect:
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:310)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:200)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at 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)
Does anyone know why I might be getting this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您解决了这个问题,但是...现在我认为 Authenticator 已被新的抽象类弃用,但我通过这种方式传递了此错误
您必须从调用
sp is myServiceSoapProxy 文件时使用的对象中获取存根对象。
我通过这种方式验证了.NET Web服务。我编码的.NET 服务经过基本身份验证。如果你得到 401 这意味着登录失败,如果你得到 403 它与 ssl 相关。
我希望这对人们有帮助。
Maybe you solved that but... for now I think Authenticator is deprecated with a new abstract class but I passed this error by this way
You must obtain your stub object from the object you use when you have a call
sp is myServiceSoapProxy file.
I authenticated .NET webservices by this way. .NET Service which I coded is basic authenticated. If you got 401 this mean login failure, if you got somewhere 403 its ssl related.
I hope this helps folks.