Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7826061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:15:23+00:00 2026-06-02T09:15:23+00:00

I have a simple WCF web service on my machine which I have developed

  • 0

I have a simple WCF web service on my machine which I have developed to serve Android and IOS devices.

The service has a single method as following :

[OperationContract]
    [WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/?message={message}")]
    string ServiceMessage(string message);

I have 3 clients , one .NET test client using HttpWebRequest which works fine , one IOS client which works fine and one Android client which I have developed with the HttpPost and HttpClient classes that fails.

Using Fiddler reverse proxy I have debugged the output of the .net client :

POST http://127.0.0.1:8888/Service1.svc/?message=_|JSON MESSAGE BODY|_HTTP/1.1
Content-Type: application/json; charset=utf-8
Host: 127.0.0.1:8888
Content-Length: 338
Expect: 100-continue
Connection: Keep-Alive

_|JSON MESSAGE BODY|_

On the other hand , this is the output of the Android HTTP Post :

POST http://10.0.2.2:8888/Service1.svc/ HTTP/1.1
Content-Type: application/json; charset=utf-8
Content-Length: 139
Host: 10.0.2.2:8888
Connection: Keep-Alive
User-Agent: Apache-HttpClient/UNAVAILABLE (java 1.4)
Expect: 100-Continue

message=_|JSON MESSAGE BODY|_

As you can see , .Net puts the message parameter on the Post at the top and does not
put the message variable name at the bottom while Android does not put the message body at the Post at the top and does put the message variable name at the bottom.

This is my Android post code ,

    HttpPost httpPost = new HttpPost(url);      
    String messageBody = "message=" + jsonMessageParameter;
    StringEntity entity = new StringEntity(messageBody);
    httpPost.setEntity(entity);
    httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
    HttpResponse response = hc.execute(httpPost);
    InputStream content = response.getEntity().getContent();
    String json = ConvertStreamToString(content);

When calling with this code , the server method is called but the message method parameter is null.
I tried playing with the Uri.Builder class to also make the android post put the message at the header , but doesnt quite work.
If can someone help me out here , I am stuck on this for hours over hours.

Thank you in advance ,

James

EDIT :

I changed the Android code to :

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
    nameValuePairs.add(new BasicNameValuePair("message", jsonMessageParameter));

    HttpPost httpPost = new HttpPost(url);
     UrlEncodedFormEntity urlEncodedFromEntity = new UrlEncodedFormEntity(
     nameValuePairs);
     urlEncodedFromEntity.setContentType(new BasicHeader("Content-Type",
     "application/json; charset=utf-8"));

    httpPost.setEntity(urlEncodedFromEntity);

    InputStream postStream = httpPost.getEntity().getContent();
    String postOutput = ConvertStreamToString(postStream);
    HttpResponse response = hc.execute(httpPost);
    InputStream content = response.getEntity().getContent();
    String json = ConvertStreamToString(content);

But still the Fiddler monitoring is as following :

POST http://10.0.2.2:8888/Service1.svc/ HTTP/1.1
Content-Length: 189
Content-Type: application/json; charset=utf-8
Host: 10.0.2.2:8888
Connection: Keep-Alive
User-Agent: Apache-HttpClient/UNAVAILABLE (java 1.4)
Expect: 100-Continue

message=_|MESSAGE_JSON|_
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:15:24+00:00Added an answer on June 2, 2026 at 9:15 am

    There a number of points here.

    First, you specifically added message= to your Android POST body:

    String messageBody = "message=" + jsonMessageParameter;
    

    This can be also problematic since you specified Content-Type: application/json but by adding message= you are not providing a valid JSON object.

    Second, why does the .Net implementation replicate the JSON object both as parameter in the URL and in the body? This looks strange and very uncommon for a POST request, and can cause problem if your JSON object makes the URL exceed the maximum URL length.

    So I would try removing message= in the body and removing the JSON object as a URL parameter, since servers processing POSTs should read the body and not the URL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a simple WCF web service in C# which returns records from
We have a simple ASP.Net WCF Ajax enabled web service which is called via
I have created an Ajax enabled WCF web service that contains this simple method:
Hello I have a simple wcf service like this, with a test method which
I created a simple WCF web service that has one method: SubmitTicket(flightticket ft, string
I have written a simple WCF web service which is configured programmaticaly. It exposes
I have a simple WCF Web service. It's hosted on IIS under the default
We have a simple WCF service that is tagged with InstanceContextMode = Single and
I have created a simple wcf service which used the WCF Service Library template.
I work with a android device which use a WCF web service. I managed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.