einfach möchte ich json als Ergebnis von .net Webservice
zu verwenden, in android appwie json als Ergebnis von .net Web-Service erhalten
meine Web-Methode ist ... erhalten
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class GetFlash : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetOneFlash()
{
string constring = System.Configuration.ConfigurationManager.ConnectionStrings["eng_lang_tutConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(constring);
con.Open();
SqlCommand sqlCommand =
new SqlCommand(@"SELECT * FROM focus WHERE P_ID = " + HttpContext.Current.Request.QueryString["IndexOrder"], con);
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
JsonWriter jsonWriter = new JsonTextWriter(sw);
try
{
SqlDataReader reader = sqlCommand.ExecuteReader();
reader.Read();
int fieldcount = reader.FieldCount; // count how many columns are in the row
object[] values = new object[fieldcount]; // storage for column values
reader.GetValues(values); // extract the values in each column
jsonWriter.WriteStartObject();
for (int index = 0; index < fieldcount; index++)
{
jsonWriter.WritePropertyName(reader.GetName(index)); // column name
jsonWriter.WriteValue(values[index]); // value in column
}
jsonWriter.WriteEndObject();
reader.Close();
}
catch (SqlException sqlException)
{
con.Close();
return ("No data fetched ..." + "\n" + "---------------------------");
}
finally
{
con.Close();
}
return sb.ToString();
}
}
meine Web-Service chaotisch - Weder es http://englishflash.somee.com/WebService/GetFlash.asmx/GetOneFlash?IndexOrder=1
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<string xmlns="http://tempuri.org/">
{"rownumber":1,"P_ID":120,"F_Eword":"a.m. ","F_Aword":"صباحا ","F_Notes":"","Usage":"","F_pic":null,"F_pronounce":"https://ssl.gstatic.com/dictionary/static/sounds/de/0/a.m..mp3"}
</string>
Der große Durchbruch ist nicht json noch xml war i in android bekam Httprequest wie diese alle
<HTML></HTML>
führen, was ich von .net webservice wie dieser gerade json brauchen
https://api.github.com/user/3bdoelnaggar
Ich verstehe nicht, warum Sie benötigen json Objekt zu kontrahieren – techspider
mit JsonWriter Sie jede zurückkehren JSon als Antwort markieren und markieren und es wird sich um alles kümmern; keine Notwendigkeit, JSON-Zeichenkette manuell vorzubereiten – techspider
sieh dir ein Beispiel hier http://www.codeproject.com/Questions/624676/JSON-Web-service-in-asp-net – techspider