As I have posted on msforums.ph about using a System.Net.WebClient to "Post" a Collection instead of posting this string postData = "client_id=" + 318 + "&tracking_id=" + 2000 thru HttpWebRequest. You can use this:
1: //Declare your Name-value Collection
2: System.Collections.Specialized.NameValueCollection objCollectionToPost = new NameValueCollection(2);
4: //populate your collection
5: objCollectionToPost.Add(“client_id”, 318);
6: objCollectionToPost.Add(“tracking_id”, 2000);
8: //Instantiate your System.Net.WebClient
9: WebClient objClient = new WebClient();
10: objClient.BaseAddress = “https:/payment.example.com/gateway”;
12: //To capture the response, you may use a byte[ array or a long string, your implementation
13: //would depend on what you think is the response will be
14: // for this instance I will use a byte array (you will notice why siguro at the end)
16: Byte objResponseCollection;
18: //This is the actual posting, you would notice that when you UploadValues to the
19: objResponseCollection = objClient.UploadValues(objClient.BaseAddress, "POST", objCollectionToPost);
21: //since most likely it would be a length of bytes, and I know from the documentation of your payment
23: //gateway, that this will be a “Comma Delimited” string, I will process it as follows
25: String objRetValues;
26: objRetValues = System.Text.Encoding.ASCII.GetString(objResponseCollection).Split(",".ToCharArray());
When you post WebClient usually returns the response of the payment gateway.
The response is usually a long string that you need to split into a specified delimiter.
In my example I already know that the gateway will return a "Comma Delimited" String based on the documentation I got from the payment provider.
For more info on WebClient go to msdn: http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx