locked
Submitting the form to 2 different Servers RRS feed

  • Question

  • User-884094897 posted
    I am working on E-Commerce section of my asp.net application,

    I have a checkout form in which there is some server controls.

    When a customer filled out the checkout form and press submit button all the submitted values are inserted in database and also I want to send the Order Number which is OrderID (Auto Generated Primary Key of my table) and an Amount to another server (to process the payment transaction) which address is some thing like:  

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

    <o:p> </o:p>

    https://ecommerce-xyz.abc.com.uk/mhost/servlet/MerchantManageServlet

    <o:p> </o:p>

    All the things are fine up to insertion in database but the problem is that how can I send the Order Number and Amount from same web form to aforesaid address using post method of FormHtmlControl because my e-merchant service provider will get these information by using Request.Form(“OrderNo”) Method.

    <o:p> 
    </o:p>

    <o:p>If anyone wants more info. about, just let me know
     </o:p>

    Thank you, urgent replay expected

    Monday, August 8, 2005 10:06 AM

All replies

  • User-1226486387 posted

    Hi there,

    you could try to post the data manually using the WebClient class.

    Here is a function I use to post data:

    private byte[] HttpPost(string uri, string data)
    {

        // Create a new WebClient instance.
        WebClient myWebClient = new WebClient();

        // Set the content type
        myWebClient.Headers.Add("Content-Type","application/x-www-form-urlencoded;charset=utf-8");

        // Apply ASCII Encoding to obtain the string as a byte array.
        byte[] byteArray = Encoding.UTF8.GetBytes(data);

        // Upload the input string using the HTTP 1.0 POST method.
        byte[] responseArray = myWebClient.UploadData(uri, "POST", byteArray);

       return responseArray;
    }

    So you could post your data like:

    string data = "OrderNo=" + your_Order_No + "&othervar=othervalue&othervar2=othervalue2";
    HttpPost("https://ecommerce-xyz.abc.com.uk/mhost/servlet/MerchantManageServlet", data);

    analysing the returned array of byte should give you the output generated by the merchand.

    Hope this help

    Monday, August 8, 2005 11:05 AM
  • User-884094897 posted
    many many thanks for your efforts, i think we are much closer to complete that task, the code i wrote so far in C# equivalent is


    Private
    Function HttpPost(ByVal uri As String, ByVal data As String) As Byte()

    Dim myWebClient As New System.Net.WebClient

    myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")

    Dim byteArray As Byte() = System.Text.Encoding.UTF8.GetBytes(data)

    Dim ResponseArray As Byte() = myWebClient.UploadData(uri, "POST", byteArray)

    HttpPost = ResponseArray

    End Function


    Private
    Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim data As String = "order_number=" + OrderNo.Text + "&total_amount=" + Amt.Text + "&user_name=" + "Samad Patel"

    HttpPost("https://ecommerce-uat.cyber.net.pk/mhost/servlet/MerchantControllerServlet", data)

    End Sub


    the problem i am facing is
    The underlying connection was closed: Could not establish trust relationship with remote server.

    even i upload that page on my remote server

    if you want to live check just go to the following URL and enter the following information repectively in the text boxes

    http://www.thecambridgeshop.com/checkorder.aspx

    in first text box enter : 7055
    and in second text box enter : 11.00

    you will see the error as i mention you , if my e-merchand testing server is on.




    Thanks for you time, i realy appriciate your reply and will on future

    Thank you

    Tuesday, August 9, 2005 5:19 AM
  • User-884094897 posted

    one thing i forget to mention, if you go to

    http://www.thecambridgeshop.com/checkorder.html

    and enter the information and press the submitt button so it eccept

    you can also check the "action" of that from by viewing the source of that form as this is html page

    thanks

    Tuesday, August 9, 2005 5:27 AM
  • User-1226486387 posted
    Ok, what's your status on this?

    What doesn't work so far?
    Monday, August 15, 2005 11:56 AM
  • User-884094897 posted
    Just view my last 2 posts, its really urgent

    Thank you
    Tuesday, August 16, 2005 3:29 AM
  • User-1226486387 posted
    Take a look at this page http://weblogs.asp.net/tgraham/archive/2004/08/12/213469.aspx
    Tuesday, August 16, 2005 8:37 AM