Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.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
Wcf 如何在windows phone 7中将字节图像发送到服务?_Wcf_Windows Phone 7 - Fatal编程技术网

Wcf 如何在windows phone 7中将字节图像发送到服务?

Wcf 如何在windows phone 7中将字节图像发送到服务?,wcf,windows-phone-7,Wcf,Windows Phone 7,我写了上面的代码以字节的形式发送图像。它没有给出任何错误。但图像没有正确上传。 我在下面的代码中传递图像的base64字符串 void SendPost() { var url = "http://{ipaddress}/Network/Records/Registration?fname=tt&lname=tt&username=dddddddd&password=tt"; Htt

我写了上面的代码以字节的形式发送图像。它没有给出任何错误。但图像没有正确上传。 我在下面的代码中传递图像的base64字符串

void SendPost()
            {
                var url = "http://{ipaddress}/Network/Records/Registration?fname=tt&lname=tt&username=dddddddd&password=tt";

                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
                myRequest.Method = "POST";
                myRequest.ContentType = "application/x-www-form-urlencoded";

                myRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), myRequest);
    }
void GetRequestStreamCallback(IAsyncResult asynchronousResult)
        {
            HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
            System.IO.Stream postStream = request.EndGetRequestStream(asynchronousResult);
            string parametersString = "";


            byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(str);
            // Write to the request stream.
            postStream.Write(byteArray, 0, byteArray.Length);
            postStream.Close();
            // Start the asynchronous operation to get the response
            request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request);
}



 void GetResponseCallback(IAsyncResult asynchronousResult)
        {

                HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
                HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
                Stream streamResponse = response.GetResponseStream();
                StreamReader streamRead = new StreamReader(streamResponse);
                string responseString = streamRead.ReadToEnd();
                // Close the stream object
                streamResponse.Close();
                streamRead.Close();
                // Release the HttpWebResponse
                response.Close();
}
请告诉我出了什么问题。为什么图像未正确上载?

请参阅以下内容:

这是:

byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(str);