Hi guys i am wondering if anyone can help.
I basically have a few thousand transactions 7,000 - 10,000 transactions to process over a short time. The flow goes like this.
<Select single record> ---> <convert to xml doc> ----> <transmit document as string to https:// location> ---> <receive a response as xml string> ---> <save response to sql)
Now i understand as i will be looking to process a few thousand at a time i need to communicate with the site asynchronously (send 1000) wait... > receive (1000) as each transaction takes approx 2 seconds so if i were to process synchronously it would take all night......
Now first i would like to ask if i am going about this the right way ?
the service i am communicating with is not .net but is built to handle large amounts of requests.
I have obtained the following code that suggests it will do what i am after
dim strxmlreq as string = '(this is where i input my xml string)
Dim request As HttpWebRequest
' Create the request
request = CType(WebRequest.Create(My.Settings.MPIURL), HttpWebRequest)
request.Method = "POST"
' Convert the xml doc string into a byte array
Dim bytes As Byte()
bytes = System.Text.Encoding.Unicode.GetBytes(strxmlreq)
' Assign the content length
request.ContentLength = bytes.Length
' Write the xml doc bytes to request stream
request.GetRequestStream.Write(bytes, 0, bytes.Length)
Dim result As IAsyncResult
Dim state As WebRequestState
Dim timeout As Integer
' Create the state object used to access the web request
state = New WebRequestState(request)
' Begin the async request
result = request.BeginGetResponse(New AsyncCallback(AddressOf RequestComplete), state)
' Set timeout at 1 minute
timeout = 1000 * 60
' Register a timeout for the async request
ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, New WaitOrTimerCallback(AddressOf TimeoutCallback), state, timeout, True)
The problem i have is if the above will work for me where exactly do i catch the returned xml string ? I assumed "result" would be the xml output string.
If anyone has any ideas or can reccomend a better way to process these transactions i would really appreciate it.
Thanks.