IT Process Automation

 View Only
  • 1.  Consuming ITPA web service in .net

    Posted Mar 25, 2011 06:40 AM
    I am trying to write a .net application which will consume the IT PA web services.

    Initially I want to be able to check the status of a process, unfortunatley I have not got very far.

    .Net creates proxy classes when you reference a web service and I am having problems with creating the Auth object to pass into my call.

    Does anyone have experience of using IT PA in .net?


  • 2.  RE: Consuming ITPA web service in .net

    Posted Feb 27, 2013 10:57 AM
    Can anyone help here please?

    I am re-visiting this and would really like to get this working.
    I am sure it is something simple.


  • 3.  RE: Consuming ITPA web service in .net

    Posted Feb 27, 2013 11:23 AM
    Hello,

    We're calling the executeProcess method from a C# exe and a powershell script.
    Here's the C# version - it does some other stuff to pass PARMs to the process, you can ignore all of that.
    Let me know if you need the powershell version.

    [font=Courier New]/// importing namespaces
    using System;
    using System.Net;
    using System.Xml;

    namespace ITPAM_WebService
    {
    static class Program
    {
    [STAThread]
    static void Main()
    {



    //Get current UTC time and get end time by adding 30min to it
    DateTime nowUTC;
    DateTime endUTC;
    nowUTC = DateTime.UtcNow;
    endUTC = nowUTC.AddMinutes(30);
    String nowUTCString = String.Format("{0:yyyy/MM/dd HH:mm}", nowUTC);
    String endUTCString = String.Format("{0:yyyy/MM/dd HH:mm}", endUTC);

    //Get AD Domain and hostname
    char[] delimiters = new char[] { '.' };
    String completeDomain = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName;
    String[] domainName = completeDomain.Split(delimiters);
    String hostName = System.Net.Dns.GetHostName();

    // Prepare SOAP URL
    String SoapURL = "<PAM Orchestrator URL>";
    String soapString = @"
    <soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:itp=""http://www.ca.com/itpam"">
    <soapenv:Header/>
    <soapenv:Body>
    <itp:executeProcess>
    <itp:flow>
    <itp:name><Process Name></itp:name>
    <itp:action>start</itp:action>
    <itp:auth>
    <!--You have a CHOICE of the next 2 items at this level-->
    <itp:user><User></itp:user>
    <itp:password><Password></itp:password>
    </itp:auth>
    <!--Optional:-->
    <itp:params>
    <!--1 or more repetitions:-->
    <itp:param name=""ipType"">ITMMaint</itp:param>
    <itp:param name=""ipName"">";
    String soapIP = @"</itp:param>
    <itp:param name=""ipRegion"">";

    String soapIPStart= @"</itp:param>
    <itp:param name=""ipStart"">";

    String soapIPEnd = @"</itp:param>
    <itp:param name=""ipEnd"">";

    String soapEnd = @"</itp:param>
    <itp:param name=""ipUseTZ"">No</itp:param>
    <itp:param name=""ipFrequency"">Once</itp:param>
    <itp:param name=""ipComments""><Comments></itp:param>
    </itp:params>
    </itp:flow>
    </itp:executeProcess>
    </soapenv:Body>
    </soapenv:Envelope>
    ";

    String soapRequestString = soapString + hostName + soapIP domainName[0] soapIPStart nowUTCString soapIPEnd endUTCStringsoapEnd;


    // Execute SOAP Request

    Console.WriteLine("Sending SOAP Request To Server: " + SoapURL);
    var soapWebRequest = System.Net.WebRequest.Create(SoapURL);
    soapWebRequest.Headers.Add("SOAPAction", "\"ExecuteC2OFlow\"");
    soapWebRequest.ContentType = "text/xml;charset=\"utf-8\"";
    soapWebRequest.Method="POST";

    Console.WriteLine(soapWebRequest.GetType());
    Console.WriteLine("Initiating Send...");

    XmlDocument soapEnvelop = new XmlDocument();
    soapEnvelop.LoadXml(soapRequestString);

    var requestStream = soapWebRequest.GetRequestStream();
    soapEnvelop.Save(requestStream);
    requestStream.Close();

    Console.WriteLine("Send Complete, Waiting For Response.");
    var resp = soapWebRequest.GetResponse();
    var responseStream = resp.GetResponseStream();
    System.IO.StreamReader soapReader = new System.IO.StreamReader(responseStream);

    Console.WriteLine(soapReader.ReadToEnd());
    Console.Read();
    }
    }
    }[font]


  • 4.  RE: Consuming ITPA web service in .net

    Posted Feb 27, 2013 12:36 PM
    nice....

    thanks for sharing!


  • 5.  RE: Consuming ITPA web service in .net

    Posted Feb 27, 2013 01:06 PM
    Thanks Jon,

    I am attempting to do it in a different way, by consuming the web service as a service reference, then using the following:

    My problem is I am trying to convert it into VB.net and having problems around the creation of the auth object.
    Itpam.ItpamServiceSoapClient TfS = new Itpam.ItpamServiceSoapClient(); // Initialize
    
    Itpam.flow UpdateClientDataFlow = new Itpam.flow() // create flow
    {
    name = "/ProcessName",
    action = "Start",
    auth = new Itpam.auth()
    {
    ItemsElementName = new Itpam.ItemsChoiceType[]
                  {
                        Itpam.ItemsChoiceType.user,
    Itpam.ItemsChoiceType.password
    },
    Items = new string[]
    {
    "UserID",
    "Password"
    }
                        },
                        @params = new Itpam.param[]
                        {
    new Itpam.param()
    {
    name = "Message",
    Value = "TestMessage"
    }
    
                        },
                        options = new Itpam.options()
                        {
    priority = "1"
                        }
    };
    
    
    TfS.ExecuteProcess(UpdateClientDataFlow); // execute 
    Anyone care to translate?


  • 6.  RE: Consuming ITPA web service in .net

    Posted Feb 27, 2013 01:13 PM
    Awesome! It would be great if share powershell script.

    thanks in advance

    -Hari


  • 7.  Re: Consuming ITPA web service in .net

    Posted Jun 24, 2014 01:20 AM