0
我想从我的Windows Phone app.The URL传递字节数组WCF服务就像下面如何字节数组传递给WCF服务
的“http:/serviceurl/Service1.svc/saverecord3 firstarray =“
我该怎么做?
我想从我的Windows Phone app.The URL传递字节数组WCF服务就像下面如何字节数组传递给WCF服务
的“http:/serviceurl/Service1.svc/saverecord3 firstarray =“
我该怎么做?
这里我的代码,我使用的数据后发送到我的服务器的一部分
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http:/serviceurl/Service1.svc/saverecord3");
req.Method = "POST";
req.ContentType = "text/xml; charset=utf-8"; //if your data is different, use a content type accordingly
string postData = @"firstarray=thedatatosend";
int length = arrayData.Length;
// Convert the string into a byte array.
byte[] byteArray = Encoding.UTF8.GetBytes(arrayData);
req.Headers[HttpRequestHeader.ContentLength] = byteArray.Length.ToString();
req.BeginGetRequestStream(ar =>
{
using (var requestStream = req.EndGetRequestStream(ar))
{
// Write the body of your request here
requestStream.Write(byteArray, 0, length);
}
req.BeginGetResponse(a =>
{
try
{
var response = req.EndGetResponse(a);
var responseStream = response.GetResponseStream();
using (var streamRead = new StreamReader(responseStream))
{
// Get the response message here
string responseString = streamRead.ReadToEnd();
//Do whatever you want here, with the response
}
}
catch (Exception e)
{
}
}, null);
}, null);
你提的问题是非常广泛的;你坚持哪个特定部分? – shambulator 2013-04-04 07:32:21