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 9015797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:50:21+00:00 2026-06-16T03:50:21+00:00

I am trying to post a json string to my wcf service. The issue

  • 0

I am trying to post a json string to my wcf service. The issue is that my WCF method expects a Stream object and not just a JSON.

Here is the method header in WCF:

    [WebInvoke(Method = "POST", UriTemplate = "person/delete", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    Person DeletePerson(Stream streamdata)

Here is what I have been trying:

    HttpPost request = new HttpPost(SERVICE_URI + uri);
    InputStream is = new ByteArrayInputStream(data.getBytes());
    InputStreamEntity ise = new InputStreamEntity(is, data.getBytes().length);
    ise.setContentType("application/x-www-form-urlencoded");
    ise.setContentEncoding(HTTP.UTF_8);
    request.setEntity(ise);
    HttpResponse response = null;
    try {
        response = client.execute(request);
    } catch (ClientProtocolException e) 
    {
        e.printStackTrace();
    } catch (IOException e) 
    {
        e.printStackTrace();
    }

I get 400 bad request with this and everything else ive tried. Could someone please help me get this working!? Also, it has to be done with HttpClient because I have custom authentication code working with it.

  • 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-16T03:50:23+00:00Added an answer on June 16, 2026 at 3:50 am
    HttpPost request = new HttpPost(SERVICE_URI + uri);
        AbstractHttpEntity entity = new AbstractHttpEntity() {
            public boolean isRepeatable() { return true; }
            public long getContentLength() { return -1; }
            public boolean isStreaming() { return false; }
            public InputStream getContent() throws IOException { throw new     UnsupportedOperationException(); }
            public void writeTo(final OutputStream outstream) throws IOException {
                Writer writer = new OutputStreamWriter(outstream, "UTF-8");
                writer.write(arr, 0, arr.length);
                writer.flush();
            }
        };
    
        entity.setContentType("application/x-www-form-urlencoded");
        entity.setContentEncoding(HTTP.UTF_8);
        request.setEntity(entity);
        HttpResponse response = null;
        InputStream bais = null;
        String result = null;
        try {
            response = client.execute(request);
            HttpEntity he = response.getEntity();
            bais = he.getContent();
            result = convertStreamToString(bais);
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (IllegalStateException e) {
            e.printStackTrace();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to post a json string to a .net wcf service. Here's the
I am trying to POST JSON to a WCF service. The json object contains
I am trying to POST JSON to a WCF service. The json object contains
I'm trying to POST a serialized object to my WCF service. However, I keep
I am having an issue trying to post a JSON string using dojo.xhrPost to
I am trying to build a REST & json based WCF service that takes
Trying to post JSON data to Spring controller.. Not working at all JSP Code:
I'm currently trying to post a JSON object from my view to my controller
I am trying to return a json string via jQuery of an object using
I'm trying to send json string in the get request to the server, here

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.