0

以下の参照リンクhttp://code.msdn.microsoft.com/Consuming-CRM-REST-Service-ae24a15eから Java ベースの CRM 実装を実装しようとしました。これらのブログから提供された手順を実行しました。で生成されたプロキシ ファイルをプロジェクトに追加しました。CRMサーバーに新しいエンティティを追加するのに苦労しています。認証の詳細で以下のスニペットを試しました

public class client { 

    /** 
     * @param args 
     */ 
    public static void main(String[] args) { 
    Authenticator a = new Authenticator() { 
            public PasswordAuthentication getPasswordAuthentication() { 
                return (new PasswordAuthentication("username", "password".toCharArray())); 
            } 
        }; 
        // Sets the default Authenticator 
        Authenticator.setDefault(a); 
        System.setProperty("java.protocol.handler.pkgs", "jcifs"); 
        Config.setProperty("jcifs.smb.client.domain", "domainname"); 
        Config.setProperty("jcifs.smb.client.username", "username"); 
        Config.setProperty("jcifs.smb.client.password", "password"); 
        Config.setProperty("jcifs.netbios.hostname","hostname"); 

        String[] arguments = { "http://crmserver/organization/xrmservices/2011/organizationdata.svc/", "c:\\crm" }; 
        Generator.main(arguments); 
    } 
    MicrosoftCrmSdkDataServicesService service = new MicrosoftCrmSdkDataServicesService(); 
    Account act = new Account(); 
    String x = UUID.randomUUID().toString(); 
    act.setAccountId(x); 
    act.setName("Account from oData"); 
    try { 
       service.addEntity(act); 
    }  
    catch (Exception e)  
    { 
        e.printStackTrace(); 
    } 

}

上記のスニペットを実行すると、 Bad Request (400) - Can't add entity to this entity setのようなエラーが発生します。これらの問題を解決するための提案があれば教えてください。

前もって感謝します!

4

0 に答える 0