1

I'm currently developing an Android app and I'm using Connect Android to MS SQL Server Tutorial to link my MSSQL server to the code.

And the first part is good though the second part is using a third party program to code which I don't want to. I want to write the whole code in C# (I'm using Xamarin).

I found out Json.NET / Json.NET for Xamarin website.

Though how am I supposed to use the HTTPUtils and requests in C# ? An example would be great.

Also, I have kind of a newbie question, I'm trying to get to the root of the code I sent, the .aspx file, and I don't quite understand where the web method is, I am used to a seperate .asmx file containing [Web Method]s that define them and then I can use them freely by creating a web reference on an .aspx file, so, where is the web method in the code I sent ?

1 Answer 1

1
public static String getJsonData(String webServiceName,String parameter)
{  
try  
{
    String urlFinal=SERVICE_URI+"/"+webServiceName+"?parameter=";
    HttpPost postMethod = new HttpPost(urlFinal.trim()+""+URLEncoder.encode(parameter,"UTF-8"));

    postMethod.setHeader("Accept", "application/json");
    postMethod.setHeader("Content-type", "application/json");

    HttpClient hc = new DefaultHttpClient();

    HttpResponse response = hc.execute(postMethod);
    Log.i("response", ""+response.toString());
    HttpEntity entity = response.getEntity();
    String responseText = EntityUtils.toString(entity);

    string=responseText;
    Log.i("Output", ""+responseText);
      }
      catch (Exception e) {
        // TODO: handle exception
    }

return string;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.