3
我正在编码使用Netbeans在Java中使用Sharepoint 2010 Web服务。我可以使用提供的向导从WSDL创建Web服务客户端。当我把下面的代码我得到的Microsoft.SharePoint.SoapServer.SoapServerException
Sharepoint 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#代码,这是我在同一台机器上运行,截至2010年的Sharepoint:
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());
}
}
}
我想这是有问题的设置,而不是用代码。