Clarity

  • 1.  XOG : SOAP : C#.NET

    Posted Feb 20, 2019 08:15 AM

    Heres a sample of SOAP XOG in C#.NET

     

    using System.Net;
    using System.xml;

    /// <summary>
    /// Summary description for Class1
    /// </summary>
    public class ClarityXog
    {
    String strUserName, strPassword, strUrl, strSessionId;

    public ClarityXog()
    {
    //
    // TODO: Add constructor logic here
    //
    }

    private XmlDocument callWebService()
    {
    using (WebClient wcConnect = new WebClient())
    {
    XmlDocument xdResponse = new XmlDocument();
    wcConnect.Headers.Add("Content-Type", "application/soap+xml; charset=utf-8");
    xdResponse.LoadXml(wcConnect.UploadString(pUrl, SOAP));
    return xdResponse;
    }
    }

    private clarityLogin()
    {
    XmlDocument xdResponse = new XmlDocument();
    XmlNamespaceManager(xdResponse.Response.NameTable);
    xnmNsMgr.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
    xnmNsMgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    xnmNsMgr.AddNamespace("", "http://www.niku.com/xog");
    string strSoap = "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:tns='http://www.niku.com/xog'><soap:Header/><soap:Body><tns:Login><tns:Username>" & pUserName & "</tns:Username><tns:Password>" & pPassword & "</tns:Password></tns:Login></soap:Body></soap:Envelope>";
    xdResponse = callWebService;
    strSessionId = xdResponse.SelectSingleNode("//soapenv:Envelope", xnmNsMgr).InnerText;
    }

    private clarityLogout()
    {
    string strSoap = "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:tns='http://www.niku.com/xog'><soap:Header/><soap:Body><tns:Logout><tns:SessionID>" & strSessionId & "</tns:SessionID></tns:Logout></soap:Body></soap:Envelope>"
    CallWebService(strSoap);
    }
    }