Sharepoint Web服务抛出Microsoft.SharePoint.SoapServer.SoapServerException

时间:2012-06-07 09:51:19

标签: java web-services sharepoint sharepoint-2010

我正在编写使用Netbeans在Java中使用Sharepoint 2010 Web服务的代码。我能够使用提供的向导从WSDL创建Web服务客户端。当我调用以下代码时,我得到Microsoft.SharePoint.SoapServer.SoapServerException

import java.net.Authenticator;
import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;

import proxy.webs.GetWebCollectionResponse;
import proxy.webs.GetWebResponse;
import proxy.webs.Webs;
import proxy.webs.WebsSoap;

public class AccessLists {

    public static void main(String[] args) throws Exception {
        String username = "domain\\Administrator";
        char[] password = "password".toCharArray();
        NtlmAuthenticator ntlmAuth = new NtlmAuthenticator(username, password);
        Authenticator.setDefault(ntlmAuth);

        Webs websService = new Webs(new URL("http://servername:7766/_vti_bin/Webs.asmx?wsdl"));
        WebsSoap webPort = websService.getWebsSoap();
        GetWebResponse.GetWebResult webRes = webPort.getWeb("http://servername/sites/Test1");
        System.out.println(webRes);
    }
}

网站http://servername/sites/Test1存在,我可以在浏览器中打开它。

更新1:类似的事情发生在C#代码上,我在与Sharepoint 2010相同的机器上运行:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Webs webService = new Webs();
            webService.Credentials = System.Net.CredentialCache.DefaultCredentials;
            Object o = webService.GetWeb("http://servername/sites/Test1");
            Console.WriteLine(o.ToString());
        }
    }
}

我想这是设置的问题,而不是代码。

1 个答案:

答案 0 :(得分:0)

我使用错误的端点进行Web服务。对于Sharepoint网站http://servername/sites/Test1,端点也应为http://servername/sites/Test1/_vti_bin/Webs.asmx?wsdl