我正在尝试在我的java类主要运行以下内容。代码使用存根来首先进行身份验证,然后在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:传输错误:401错误:未经授权 在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) at 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)
有谁知道为什么我会这么做?
答案 0 :(得分:0)
也许你已经解决了这个问题,但是......现在我认为Authenticator已被弃用了一个新的抽象类但我通过这种方式传递了这个错误
your_stub_object._setProperty(Stub.USERNAME_PROPERTY, "loginname");
your_stub_object._setProperty(Stub.PASSWORD_PROPERTY, "loginsecret");
您必须从通话时使用的对象中获取存根对象
javax.xml.rpc.Stub your_stub_object=((javax.xml.rpc.Stub)(sp.getService1Soap()));
sp是myServiceSoapProxy文件。
我通过这种方式验证了.NET webservices。我编写的.NET服务是基本认证的。如果你得到401这意味着登录失败,如果你在某个地方403 ssl相关。
我希望这对人们有所帮助。