SSIS C#脚本任务utf-16到utf-8
这是我目前的代码:SSIS C#脚本任务utf-16到utf-8,c#,encoding,utf-8,ssis,C#,Encoding,Utf 8,Ssis,这是我目前的代码: public void Main() { const string URL = @"mywebservice"; HttpWebRequest req = WebRequest.Create(URL) as HttpWebRequest; req.Timeout = 600000; HttpWebResponse response = req.GetResponse() as HttpWebR
public void Main()
{
const string URL = @"mywebservice";
HttpWebRequest req = WebRequest.Create(URL) as HttpWebRequest;
req.Timeout = 600000;
HttpWebResponse response = req.GetResponse() as HttpWebResponse;
XmlTextReader reader = new XmlTextReader(response.GetResponseStream());
string filePath = Dts.Variables["xmlFile"].Value.ToString();
TextWriter file = new StreamWriter(filePath, false, Encoding.UTF8);
using (file)
{
XmlDocument doc = new XmlDocument();
XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
doc.AppendChild(xmlDeclaration);
doc.Load(reader);
doc.Save(file);
}
Dts.TaskResult = (int)ScriptResults.Success;
}
我试图从中提取的web服务是用utf-16编写的,它需要用utf-8编写。我知道我的代码可能有一些冗余,但我目前收到的错误似乎并没有给我指明任何方向。以下是我当前的错误。任何帮助都会被占用的,谢谢
位于System.RuntimeMethodHandle.InvokeMethod(对象目标,对象[])
参数、签名sig、布尔构造函数)
位于System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(对象
obj,对象[]参数,对象[]参数)
在System.Reflection.RuntimeMethodInfo.Invoke(对象obj,
BindingFlags invokeAttr,Binder Binder,对象[]参数,
文化信息(文化)
在System.RuntimeType.InvokeMember处(字符串名称,BindingFlags
bindingFlags、绑定器绑定器、对象目标、对象[]提供的参数、,
ParameterModifier[]修饰符,CultureInfo区域性,字符串[]
命名参数)
在
Microsoft.SqlServer.Dts.Tasks.ScriptTask.vstatasksscriptingEngine.ExecuteScript()
我在你发布的堆栈跟踪中没有看到错误。还有其他的吗?不幸的是,这就是堆栈中的全部内容。它声明“异常已被调用的目标抛出。”