我是脚本新手(SSIS 也是新手);我正在尝试使用 Web 服务 URL 并尝试从中生成 XML。Web 服务的配置方式,我不能在 SSIS 中使用 Web 服务任务,所以我尝试使用脚本任务,但我得到了一些“绑定错误”。我搜索并阅读了很多在线文章,但由于我没有太多的脚本编写经验,我不断收到错误消息:
#region Namespaces
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
#endregion
namespace ST_c9ff0d0cdf0a455e804af51f85eb8494
{
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure,
};
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public void Main()
{
var binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic;
binding.Security.Transport.Realm = "";
binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
var endpointAddress = new EndpointAddress("Web Service URL");
dmvcrashns.RMSIntegrationServiceSoapClient soapClient = new dmvcrashns.RMSIntegrationServiceSoapClient(binding, endpointAddress);
soapClient.ClientCredentials.UserName.UserName = "username";
soapClient.ClientCredentials.UserName.Password = "password";
dmvcrashns.FindLEApprovedCrashesRequest r = new dmvcrashns.FindLEApprovedCrashesRequest();
r.pStart = new DateTime(2016, 09, 01);
r.pEnd = new DateTime(2017, 01, 01);
dmvcrashns.RMSIntegrationServiceSoapClient c = new dmvcrashns.RMSIntegrationServiceSoapClient();
var resp = c.FindLEApprovedCrashes(new dmvcrashns.TREDSCredentials() {
Password = "username",
UserName = "password" },
r.pStart, r.pEnd);
}
}
}
错误信息:
Could not find default endpoint element that references contract 'dmvcrashns.RMSIntegrationServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.