RightNow CRM XML API - 有谁熟悉它?

时间:2008-09-26 14:59:12

标签: c# asp.net xml vb.net rightnow-crm

我需要在vb.net或c#中创建用户控件来搜索RightNow CRM数据库。我有关于他们的XML API的文档,但我不确定如何发布到他们的解析器,然后捕获返回数据并将其显示在页面上。

非常感谢任何示例代码!

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

2 个答案:

答案 0 :(得分:1)

我不知道RightNow CRM,但根据文档,您可以使用HTTP post发送XML请求。在.NET中执行此操作的最简单方法是使用WebClient类。或者,您可能需要查看HttpWebRequest / HttpWebResponse类。以下是使用WebClient的一些示例代码:

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,所以我无法对此进行测试,但它可以作为您的终点。

答案 1 :(得分: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 = "mail@mail.com";
        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();

    }
}