Клиент SSIS C # для отправки запроса SOAP и получения ответа - PullRequest
1 голос
/ 23 апреля 2019

Я пытаюсь создать сценарий C # SSIS, который отправляет запросы SOAP веб-службе (и получает результаты).

Я видел код здесь: Клиент для отправки запроса SOAP и получения ответа

У меня была ошибка, но я не могу выполнить отладку в ssis.У меня возникла ошибка Невозможно выполнить сценарий, поскольку точка входа сценария недействительна »в задаче сценария в службах SSIS Это мой код:

   namespace ST_75982b92bbab4c2594c76b05097b7cd1
{
    /// <summary>
    /// ScriptMain is the entry point class of the script.  Do not change the name, attributes,
    /// or parent of this class.
    /// </summary>
    [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {


        public static HttpWebRequest CreateWebRequest()
        {
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(@"https://preprod.secureholiday.net/ASPX/ShProcess/Api.asmx?wsdl");
            webRequest.Headers.Add(@"SOAP:Action");
            webRequest.ContentType = "text/xml;charset=\"utf-8\"";
            webRequest.Accept = "text/xml";
            webRequest.Method = "POST";
            return webRequest;
        }

        public static void Execute()
        {
            // TODO: Add your code here

            HttpWebRequest request = CreateWebRequest();
            XmlDocument soapEnvelopeXml = new XmlDocument();
            soapEnvelopeXml.LoadXml(@"<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:web=""http://webservices.secureholiday.net/"">
   <soapenv:Header/>
   <soapenv:Body>
      <web:SetPricingGrid>
         <web:User>
            <web:idEngine>XXXX</web:idEngine>
            <web:password>XXXX</web:password>
            <web:user>XXXX</web:user>
         </web:User>
         <web:PricingGrid>
            <web:GridConfiguration>
               <web:EstablishmentId>15509</web:EstablishmentId>
               <web:ProductId>81332</web:ProductId>
               <!--<web:GridId>269614</web:GridId>-->
               <web:GridModel>ByNight</web:GridModel>
               <web:Visibility>Yield</web:Visibility>
               <web:PublicNames>
                  <web:PublicName>
                     <web:Lg>FR</web:Lg>
                     <web:Label>Grille nuitée Yield FNS 24/04/2019 11h29</web:Label>
                  </web:PublicName>
               </web:PublicNames>
               <!--<web:ExclusiveEngineIds>
                  <web:int>1554</web:int>
               </web:ExclusiveEngineIds>-->
               <web:IsEstablishmentValidationRequired>false</web:IsEstablishmentValidationRequired>
            </web:GridConfiguration>
            <web:PricingConfiguration>
               <web:Account>
                  <web:AccountModel>Percent</web:AccountModel>
                  <web:Value>30</web:Value>
               </web:Account>
               <web:BookingFeesPrice>10</web:BookingFeesPrice>
               <web:Person>
                  <web:MinPersonQuantity>4</web:MinPersonQuantity>
                  <web:MaxPersonQuantity>6</web:MaxPersonQuantity>
                  <web:IncludedPersonQuantity>4</web:IncludedPersonQuantity>
               </web:Person>
            </web:PricingConfiguration>
            <web:PricingPeriods>
               <!--Zero or more repetitions:-->
               <web:PricingPeriod>
                  <web:StartDate>2019-04-01</web:StartDate>
                  <web:IncludedEndDate>2019-06-30</web:IncludedEndDate>
                  <web:Price>20</web:Price>
                  <web:StayDuration>
                     <web:DurationModel>GreaterThanOrEqual</web:DurationModel>
                     <web:NightQuantity>3</web:NightQuantity>
                  </web:StayDuration>
               </web:PricingPeriod>
               <web:PricingPeriod>
                  <web:StartDate>2019-07-01</web:StartDate>
                  <web:IncludedEndDate>2019-08-31</web:IncludedEndDate>
                  <web:Price>35</web:Price>
                  <web:StayDuration>
                     <web:DurationModel>GreaterThanOrEqual</web:DurationModel>
                     <web:NightQuantity>7</web:NightQuantity>
                  </web:StayDuration>
               </web:PricingPeriod>
               <web:PricingPeriod>
                  <web:StartDate>2019-09-01</web:StartDate>
                  <web:IncludedEndDate>2019-10-15</web:IncludedEndDate>
                  <web:Price>25</web:Price>
                  <web:StayDuration>
                     <web:DurationModel>GreaterThanOrEqual</web:DurationModel>
                     <web:NightQuantity>2</web:NightQuantity>
                  </web:StayDuration>
               </web:PricingPeriod>
            </web:PricingPeriods>
         </web:PricingGrid>
      </web:SetPricingGrid>
   </soapenv:Body>
</soapenv:Envelope>");

            using (Stream stream = request.GetRequestStream())
           {
               soapEnvelopeXml.Save(stream);
            }

           using (WebResponse response = request.GetResponse())
           {
               using (StreamReader rd = new StreamReader(response.GetResponseStream()))
            {
                  string soapResult = rd.ReadToEnd();
                   Console.WriteLine(soapResult);

             }
           }


        }

         static void Main(string[] args)
        {
            Execute();
        }


        #region ScriptResults declaration
        /// <summary>
        /// This enum provides a convenient shorthand within the scope of this class for setting the
        /// result of the script.
        /// 
        /// This code was generated automatically.
        /// </summary>
        enum ScriptResults
        {
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        };
        #endregion

    }
}
...