【发布时间】: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