使用 Axis2 客户端身份验证调用 SharePoint Web 服务

发布于 2024-09-27 08:11:26 字数 2606 浏览 1 评论 0原文

我正在尝试在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪痕残 2024-10-04 08:11:26

也许您解决了这个问题,但是...现在我认为 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 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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文