mardi 28 novembre 2017

Create SOAP request in UFT API from Excel

I have an Excel file with the Soap request parameter values, I need to generate soap request using those values. I have done a normal request using c# which is hard coded.

public void StServiceCallActivity4_OnAfterGenerateRequest(object sender, HP.ST.Ext.WebServicesActivities.ActivityProcessXmlMessageEventArgs args)
    {
        string action = GetDataSource("InputSheet!Sheet1").GetValue(this.Loop2.CurrentIterationNumber-1, "action").ToString();
        //string action = "modify";
        string actionXpath = "/*[local-name(.)='Envelope'][1]/*[local-name(.)='Body'][1]/*[local-name(.)='captureInteractionRequest'][1]/*[local-name(.)='interaction'][1]/*[local-name(.)='body'][1]/*[local-name(.)='item'][1]/*[local-name(.)='service'][1]/*[local-name(.)='action'][1]";

        this.StServiceCallActivity4.InputEnvelope.SelectSingleNode(actionXpath).InnerText = action;



        string nameXpath="/*[local-name(.)='Envelope'][1]/*[local-name(.)='Body'][1]/*[local-name(.)='captureInteractionRequest'][1]/*[local-name(.)='interaction'][1]/*[local-name(.)='body'][1]/*[local-name(.)='item'][1]/*[local-name(.)='parameter'][1]/*[local-name(.)='value'][1]";
        this.StServiceCallActivity4.InputEnvelope.SelectSingleNode(nameXpath).InnerText = GetDataSource("InputSheet!Sheet1").GetValue(this.Loop2.CurrentIterationNumber-1, "NAME").ToString();


    }

I need to create each parameter with code (here i done manually)

   <invbi:parameter>
      <invbi:name>NAME</invbi:name>
      <invbi:value xsi:type="xs:string"></invbi:value>
   </invbi:parameter>

Aucun commentaire:

Enregistrer un commentaire