#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Posts
    1
    Rep Power
    0

    How to consuming WCF in android


    Hi All,

    I have created a simple WCF service and deploy it on internal server and trying to access it in my android application. Below is the code.

    WCF: IService.cs
    [XmlSerializerFormat(Style = OperationFormatStyle.Document, Use = OperationFormatUse.Literal)]
    [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Xml,
    Method = "GET", ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/GetUserForTest")]
    string GetUserForTest();

    Service.cs
    public string GetUserForTest()
    {
    return "Result from Service";
    }

    Code for Android:
    Button bSearchUser = (Button) findViewById(R.id.bSearchUser);
    TextView firstName = (TextView) findViewById(R.id.txtFstName);
    bSearchUser.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {

    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpGet request = new HttpGet(User_Service_URL+"/GetUserForTest");
    request.setHeader("Accept", "application/xml");
    request.setHeader("Content-type", "application/xml");
    try {
    HttpResponse response = httpClient.execute(request);
    HttpEntity entity = response.getEntity();
    String result = EntityUtils.toString(entity);
    firstName.setText(result);

    } catch (ClientProtocolException e) {
    e.printStackTrace();

    } catch (IOException e) {
    e.printStackTrace();
    }
    }

    });

    The Client code[android code] returns: <html><body><p>File does not exist</p></body></html>

    Please let me know what is going wrong in my code.

    Thanks in Advance.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2014
    Posts
    1
    Rep Power
    0

    Только тут са&


    Сколько уже можно безрезультатно просиживать в интернете? Добро пожаловать к нам, т.к. тут можно найти
    свежие новости. Всем успехов!

IMN logo majestic logo threadwatch logo seochat tools logo