HTTP连接管理器中的动态sourceURL,用于每个循环

时间:2015-11-10 12:47:47

标签: vb.net http ssis httprequest

我有一个返回多个ID的SQL语句。我想为每个ID制作一个http请求。

一切都在循环的第一次迭代中起作用,但第二次崩溃。我收到以下错误:

   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

流程如下:

enter image description here

脚本中的代码如下所示:

Public Sub Main()
        'connecting website using HTTP connection manager
        Dim nativeObject As Object = Dts.Connections("HTTP Connection Manager").AcquireConnection(Nothing)

        ' Create a new HTTP client connection
        Dim connection As New HttpClientConnection(nativeObject)

        'Download the html page to your local drive
        connection.DownloadFile("C:\temp\samtykker.txt", True)

        MsgBox(Dts.Variables("cID").Value.ToString)

        Dim streamReader As New StreamReader("C:\temp\samtykker.txt")

        Dim streamText As String = streamReader.ReadToEnd
        Dts.Variables("fileContent").Value = streamText

        Dim indexWithAnswer As Integer = InStr(10000, streamText, "<span id=""ConsentEntryCtrl_Lbl_SamtykkeMotattMeldingValue"" class=""Text"">", CompareMethod.Text)
        Dim startIndex As Integer = InStr(indexWithAnswer, streamText, "NEI", CompareMethod.Text)

        Dim answer As String = If(startIndex = 0, "JA", streamText.Substring(startIndex - 1, 3))

        MsgBox(answer.ToString())

    End Sub

我在网上找不到任何有用的内容,所以非常感谢任何帮助

0 个答案:

没有答案