这是我目前的代码:
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中。我知道我的代码可能有一些冗余,但我收到的当前错误似乎并没有指向任何方向。这是我目前的错误。任何帮助都会被挪用,谢谢。
at System.RuntimeMethodHandle.InvokeMethod(Object target,Object [] arguments,Signature sig,Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object []参数,Object []参数)
在System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr,Binder binder,Object []参数, 文化信息文化)
at System.RuntimeType.InvokeMember(String name,BindingFlags bindingFlags,Binder binder,Object target,Object [] providedArgs, ParameterModifier []修饰符,CultureInfo文化,String [] namedParams)
在 Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()