C# SSIS脚本任务soap web服务调用错误
我在SSIS脚本任务中调用基于soap的web服务。web服务需要用户名、密码和guid才能工作。在从SSIS脚本任务调用web服务之前,我已经成功地从控制台应用程序调用了web服务。 这是我的C代码:C# SSIS脚本任务soap web服务调用错误,c#,web-services,soap,ssis,C#,Web Services,Soap,Ssis,我在SSIS脚本任务中调用基于soap的web服务。web服务需要用户名、密码和guid才能工作。在从SSIS脚本任务调用web服务之前,我已经成功地从控制台应用程序调用了web服务。 这是我的C代码: public void Main() { // TODO: Add your code here // TODO: Add your code here MessageBox.Sho
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;
}
这是我的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”
客户端配置部分。这可能是因为没有配置
找不到应用程序的文件,或者因为没有端点元素
在client元素中可以找到与此合同匹配的内容
要使脚本中的SSIS web服务正常工作,需要什么?
问候。试着用这种方式:
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");
问题是脚本任务不支持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);
如果客户端创建得很好,那么您就可以开始了。您好,我尝试了两个方案,但都出现了相同的错误…我将尝试手动设置web服务,看看是否有效。。。
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);