【问题标题】:SSIS script task soap web service call errorSSIS脚本任务soap web服务调用错误
【发布时间】:2017-06-08 03:44:55
【问题描述】:

我在 SSIS 脚本任务中调用基于肥皂的 Web 服务。 Web 服务需要用户名、密码和 guid 才能工作。在从 SSIS 脚本任务调用 Web 服务之前,我已经成功地从控制台应用程序调用了 Web 服务。 这是我的 C 语言代码:

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

                        // TODO: Add your code here
            MessageBox.Show((string)Dts.Variables["ServiceDateStart"].Value);

            string userName = "xxx";
            string password = "xxx";
            string licenceID = "xxx";
            ServiceReference.AuthenticationHeader a = new ServiceReference.AuthenticationHeader();
            a.LicenceID = new Guid(licenceID);
            a.UserName = userName;
            a.Password = password;
            ServiceReference.CompanyAccountXmlServiceSoapClient service = new ServiceReference.CompanyAccountXmlServiceSoapClient();

            string result;
            long numberOfResults;
            int counter1 = 0;
            int counter2 = 19;



            do
            {



               result = service.GetCompanyAccountUpdated(a, (string)Dts.Variables["ServiceDateStart"].Value, (string)Dts.Variables["ServiceDateEnd"].Value, counter1, counter2);
               //result = service.GetCompanyAccountUpdated(a, "20150101", "20150107", counter1, counter2);
                counter1 = counter1 + 20;
                counter2 = counter2 + 20;



                using (System.IO.StreamWriter file =
      new System.IO.StreamWriter(@"C:\Users\jkrneta\Documents\GetCompanyAccountUpdated.txt", true))
             {


                 file.WriteLine(result);


             }

            } while (!result.Equals("<CompanyAccountDataSet />"));


            Dts.TaskResult = (int)ScriptResults.Success;
        }

代码在我调用网络服务的地方失败:

ServiceReference.CompanyAccountXmlServiceSoapClient service = new ServiceReference.CompanyAccountXmlServiceSoapClient();

这是我的 app.config 文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="CompanyAccountXmlServiceSoap">
                    <security mode="Transport" />
                </binding>
                <binding name="CompanyAccountXmlServiceSoap1" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://webservices.nbs.rs/CommunicationOfficeService1_0/CompanyAccountXmlService.asmx"
                binding="basicHttpBinding" bindingConfiguration="CompanyAccountXmlServiceSoap"
                contract="ServiceReference.CompanyAccountXmlServiceSoap" name="CompanyAccountXmlServiceSoap" />
        </client>
    </system.serviceModel>
</configuration>

我在调试模式下运行服务时遇到的错误是:

找不到引用合约的默认端点元素 ServiceModel 中的“ServiceReference.CompanyAccountXmlServiceSoap” 客户端配置部分。这可能是因为没有配置 为您的应用程序找到了文件,或者因为没有端点元素 可以在客户端元素中找到与此合同相匹配的内容。

需要什么才能使我的 SSIS Web 服务从脚本工作? 问候。

【问题讨论】:

    标签: c# web-services soap ssis


    【解决方案1】:

    尝试这样使用:

    ServiceReference.CompanyAccountXmlServiceSoapClient service = 
    new  ServiceReference.CompanyAccountXmlServiceSoapClient("CompanyAccountXmlServiceSoap");
    

    其他选项是:

    Reload the service reference of your project.
    

    只是给你一个想法:

    根据我自己的经验,我确实为我的代码设置了一个端点地址,如下所示:

    service.Endpoint.Address = new System.ServiceModel.EndpointAddress("https://webservices.nbs.rs/CommunicationOfficeService1_0/CompanyAccountXmlService.asmx");
    

    【讨论】:

    • 您好,我尝试了这两个建议,但都遇到相同的错误...我将尝试手动设置 Web 服务,看看是否有效...
    【解决方案2】:

    问题是脚本任务不支持 app.config,所以你的配置没有发挥作用。请尝试在代码中设置所有组件,如下所示:

                EndpointAddress endpointAdress = new 
     EndpointAddress("https://webservices.nbs.rs/CommunicationOfficeService1_0/CompanyAccountXmlService.asmx");
                BasicHttpBinding binding1 = new BasicHttpBinding();
                binding1.Security.Mode = BasicHttpSecurityMode.Transport;
                var client = new ServiceReference.CompanyAccountXmlServiceSoapClient(binding1, endpointAdress);
    

    如果客户端创建得很好,那么你就可以开始了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-05
      • 1970-01-01
      相关资源
      最近更新 更多