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 开发者_如何学JAVA 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?
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
your_stub_object._setProperty(Stub.USERNAME_PROPERTY, "loginname");
your_stub_object._setProperty(Stub.PASSWORD_PROPERTY, "loginsecret");
You must obtain your stub object from the object you use when you have a call
javax.xml.rpc.Stub your_stub_object=((javax.xml.rpc.Stub)(sp.getService1Soap()));
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.
精彩评论