2
임에서 사용자 정의 된 값을 반환하는 방법 :그것의 반환 값은 다음과 같이 JSON에 내 프로젝트에서 REST 웹 서비스를 사용하여 REST 웹 서비스
[{"MsgID":"92817137","Status":"0","SendTime":"2014-06-11 14:17:40","DeliverTime":"0000-00-00 00:00:00"}]
을하지만 그 모두에게 필요가없는, I "Statues"태그가 필요합니다. 내가 어떻게 할 수 있니?
내 반환 값이처럼 원하는private void btnCheckStatus_Click(object sender, EventArgs e)
{
Uri address = new Uri("http://www.asanak.ir/webservice/v1rest/msgstatus");
// Create the web request
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
// Set type to POST
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
// Create the data we want to send
StringBuilder data = new StringBuilder();
data.Append("username=" + textUserName.Text.Trim());
data.Append("&password=" + textPassword.Text.Trim());
data.Append("&msgid=" + textMsgId.Text.Trim());
// Create a byte array of the data we want to send
byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());
// Set the content length in the request headers
request.ContentLength = byteData.Length;
// Write data
using (Stream postStream = request.GetRequestStream())
{
postStream.Write(byteData, 0, byteData.Length);
}
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
textResult.Text = reader.ReadToEnd();
}
}
: 귀하 께서 웹 서비스의 방법을 변경할 수없는 경우 "Status":"0"
감사
반환 값은 무엇을 의미합니까? 이 메서드 (btnCheckStatus_Click)는 아무 것도 반환하지 않습니다. 웹 서비스에서 Status 값을 읽으려고합니까? – Axarydax
@Axarydax 예, 웹 서비스에서 상태 값만 읽으려고합니다 ... 위의 코드로 모든 것을 읽었습니다 ... – Elahe