Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google checkout与.NET的集成_.net_Xml_Google Checkout - Fatal编程技术网

Google checkout与.NET的集成

Google checkout与.NET的集成,.net,xml,google-checkout,.net,Xml,Google Checkout,我正在尝试使用服务器到服务器的XMLAPI来使用c#.NET3.5进行google签出 当我尝试发布我的URL“远程服务器返回了一个错误:(400)错误请求”时,我遇到了以下错误。尽管我确信我完全按照他们的指示进行了操作。我的代码在下面。。。有人帮忙吗 public void DoWebRequest(string content) { //Save the content string for later use _checkoutString

我正在尝试使用服务器到服务器的XMLAPI来使用c#.NET3.5进行google签出

当我尝试发布我的URL“远程服务器返回了一个错误:(400)错误请求”时,我遇到了以下错误。尽管我确信我完全按照他们的指示进行了操作。我的代码在下面。。。有人帮忙吗

    public void DoWebRequest(string content)
    {
        //Save the content string for later use
        _checkoutString = content;

        // Create a new request to the mentioned URL.    
        WebRequest myWebRequest = WebRequest.Create("https://sandbox.google.com/checkout/api/checkout/v2/merchantCheckout/Merchant/" + Utils.MerchantData.Id);

        //Create authorisation key
        string encodeKey = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(Utils.MerchantData.Id + ":" + Utils.MerchantData.Key));

        // Create an instance of the RequestState and assign 'myWebRequest' to it's request field.    
        RequestState myRequestState = new RequestState();
        myRequestState.request = myWebRequest;
        myWebRequest.ContentType = "application/xml; charset=UTF-8";
        //myWebRequest.Accept = 
        //myWebRequest.Headers["Accept"] = "application/xml; charset=UTF-8";
        ((HttpWebRequest)myWebRequest).Accept = "application/xml; charset=UTF-8";
        myWebRequest.Headers.Add("Authorization", "Basic " + encodeKey);

        // Set the 'Method' property  to 'POST' to post data to a Uri.
        myRequestState.request.Method = "POST";

        // Start the Asynchronous 'BeginGetRequestStream' method call.    
        IAsyncResult r = (IAsyncResult)myWebRequest.BeginGetRequestStream(new AsyncCallback(ReadCallback), myRequestState);

        // Pause the current thread until the async operation completes.
        _allDone.WaitOne();

        // Assign the response object of 'WebRequest' to a 'WebResponse' variable.
        WebResponse myWebResponse = myWebRequest.GetResponse();
        Stream streamResponse = myWebResponse.GetResponseStream();
        StreamReader streamRead = new StreamReader(streamResponse);
        Char[] readBuff = new Char[256];
        int count = streamRead.Read(readBuff, 0, 256);

        while (count > 0)
        {
            String outputData = new String(readBuff, 0, count);
            Debug.Write(outputData);
            count = streamRead.Read(readBuff, 0, 256);
        }

        // Close the Stream Object.
        streamResponse.Close();
        streamRead.Close();

        // Release the HttpWebResponse Resource.
        myWebResponse.Close();      
    }

    private static void ReadCallback(IAsyncResult asynchronousResult)
    {
        RequestState myRequestState = (RequestState)asynchronousResult.AsyncState;
        WebRequest myWebRequest = myRequestState.request;

        // End the Asynchronus request.
        Stream streamResponse = myWebRequest.EndGetRequestStream(asynchronousResult);

        // Convert the string into a byte array.
        byte[] byteArray = Encoding.UTF8.GetBytes(_checkoutString);

        // Write the data to the stream.
        streamResponse.Write(byteArray, 0, _checkoutString.Length);
        streamResponse.Close();
        _allDone.Set();
    }
我在以下行中得到错误:

        WebResponse myWebResponse = myWebRequest.GetResponse();
我的“内容”字符串如下所示:

            string googleCheckoutString =
            "<!-- Sell physical goods with tax and shipping -->" +
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
            "<checkout-shopping-cart xmlns=\"http://checkout.google.com/schema/2\">" +
            "<shopping-cart>" +
            "<items>" +
            products +
            "</items>" +
            "</shopping-cart>" +
            "<checkout-flow-support>" +
            "<merchant-checkout-flow-support>" +
            "<shipping-methods>" +
            shipping +
            "</shipping-methods>" +
            "</merchant-checkout-flow-support>" +
            "</checkout-flow-support>" +
            "</checkout-shopping-cart>";
string googleCheckoutString=
"" +
"" +
"" +
"" +
"" +
产品+
"" +
"" +
"" +
"" +
"" +
船运+
"" +
"" +
"" +
"";