3

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: Sharepoint 2010 と同じマシンで実行する C# コードでも同様のことが起こります。

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());
        }
    }
}

これはコードの問題ではなく、セットアップの問題だと思います。

4

1 に答える 1

0

Web サービスに間違ったエンドポイントを使用していました。Sharepoint サイトhttp://servername/sites/Test1の場合、エンドポイントもhttp://servername/sites/Test1/_vti_bin/Webs.asmx?wsdl

于 2012-06-09T20:22:57.433 に答える