2008-09-26 21 views
1

我需要在vb.net或c#中创建一个用户控件来搜索RightNow CRM数据库。我有他们的XML API的文档,但我不知道如何发布到他们的解析器,然后捕获返回数据并将其显示在页面上。RightNow CRM XML API - 任何熟悉它的人?

任何示例代码将不胜感激!

链接到API:http://community.rightnow.com/customer/documentation/integration/82_crm_integration.pdf

+0

你能链接到他们的文档?其他人可能能够找到它的相关信息,即使我们没有RightNow的经验... – 2008-09-26 15:08:38

回答

1

我不知道了RightNow CRM,而是根据文档,您可以发送使用HTTP岗位XML请求。在.NET中最简单的方法是使用WebClient类。或者你可能想看看HttpWebRequest/HttpWebResponse类。下面是一些示例代码中使用Web客户端:

using System.Net; 
using System.Text; 
using System; 

namespace RightNowSample 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      string serviceUrl = "http://<your_domain>/cgi-bin/<your_interface>.cfg/php/xml_api/parse.php"; 
      WebClient webClient = new WebClient(); 
      string requestXml = 
@"<connector> 
<function name=""ans_get""> 
<parameter name=""args"" type=""pair""> 
<pair name=""id"" type=""integer"">33</pair> 
<pair name=""sub_tbl"" type='pair'> 
<pair name=""tbl_id"" type=""integer"">164</pair> 
</pair> 
</parameter> 
</function> 
</connector>"; 

      string secString = ""; 
      string postData = string.Format("xml_doc={0}, sec_string={1}", requestXml, secString); 
      byte[] postDataBytes = Encoding.UTF8.GetBytes(postData); 

      byte[] responseDataBytes = webClient.UploadData(serviceUrl, "POST", postDataBytes); 
      string responseData = Encoding.UTF8.GetString(responseDataBytes); 

      Console.WriteLine(responseData); 
     } 
    } 
} 

我要了RightNow CRM进不去了,所以我不能对此进行测试,但它可以成为为S tarting点为您服务。

0

这将创建一个右键联系

class Program 
{ 
    private RightNowSyncPortClient _Service; 
    public Program() 
    { 
     _Service = new RightNowSyncPortClient(); 
     _Service.ClientCredentials.UserName.UserName = "Rightnow UID"; 
     _Service.ClientCredentials.UserName.Password = "Right now password"; 
    } 
    private Contact Contactinfo() 
    { 
     Contact newContact = new Contact(); 
     PersonName personName = new PersonName(); 
     personName.First = "conatctname"; 
     personName.Last = "conatctlastname"; 
     newContact.Name = personName; 
     Email[] emailArray = new Email[1]; 
     emailArray[0] = new Email(); 
     emailArray[0].action = ActionEnum.add; 
     emailArray[0].actionSpecified = true; 
     emailArray[0].Address = "[email protected]"; 
     NamedID addressType = new NamedID(); 
     ID addressTypeID = new ID(); 
     addressTypeID.id = 1; 
     addressType.ID = addressTypeID; 
     addressType.ID.idSpecified = true; 
     emailArray[0].AddressType = addressType; 
     emailArray[0].Invalid = false; 
     emailArray[0].InvalidSpecified = true; 
     newContact.Emails = emailArray; 
     return newContact; 
    } 
    public long CreateContact() 
    { 
     Contact newContact = Contactinfo(); 
     //Set the application ID in the client info header 
     ClientInfoHeader clientInfoHeader = new ClientInfoHeader(); 
     clientInfoHeader.AppID = ".NET Getting Started"; 
     //Set the create processing options, allow external events and rules to execute 
     CreateProcessingOptions createProcessingOptions = new CreateProcessingOptions(); 
     createProcessingOptions.SuppressExternalEvents = false; 
     createProcessingOptions.SuppressRules = false; 
     RNObject[] createObjects = new RNObject[] { newContact }; 
     //Invoke the create operation on the RightNow server 
     RNObject[] createResults = _Service.Create(clientInfoHeader, createObjects, createProcessingOptions); 

     //We only created a single contact, this will be at index 0 of the results 
     newContact = createResults[0] as Contact; 
     return newContact.ID.id; 
    } 

    static void Main(string[] args) 
    { 
     Program RBSP = new Program(); 
     try 
     { 
      long newContactID = RBSP.CreateContact(); 
      System.Console.WriteLine("New Contact Created with ID: " + newContactID); 
     } 
     catch (FaultException ex) 
     { 
      Console.WriteLine(ex.Code); 
      Console.WriteLine(ex.Message); 
     } 

     System.Console.Read(); 

    } 
}