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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:39:01+00:00 2026-05-26T10:39:01+00:00

I have the following contract: [OperationContract(Name = Upload)] [WebInvoke(Method = POST, UriTemplate = /Upload/{step}/{fileName},

  • 0

I have the following contract:

[OperationContract(Name = "Upload")]
        [WebInvoke(Method = "POST", UriTemplate = "/Upload/{step}/{fileName}",
            BodyStyle= WebMessageBodyStyle.WrappedRequest)]
        Response FileUpload(string fileName, string step, Stream fileStream);

And the implementation:

public Response FileUpload(string fileName, string step, Stream fileStream)
        {
            FileStream fileToUpload = new FileStream("C:\\inetpub\\wwwroot\\Upload\\" + fileName, FileMode.Create);

            byte[] bytearray = new byte[10000];
            int bytesRead, totalBytesRead = 0;
            do
            {
                bytesRead = fileStream.Read(bytearray, 0, bytearray.Length);
                totalBytesRead += bytesRead;
            } while (bytesRead > 0);

            fileToUpload.Write(bytearray, 0, bytearray.Length);
            fileToUpload.Close();
            fileToUpload.Dispose();

            Response res = new Response();
            res.Successful = true;
            res.Comment = "Bla bla";
            return res;
        }

And configuration:

 <system.serviceModel>
    <client>
      <endpoint address="" binding="webHttpBinding"
                bindingConfiguration="StreamHTTP"
                contract="BillboardServices.IBillboardService"
      />
    </client>
    <bindings>
      <webHttpBinding>
        <binding name="StreamedHTTP"
                 transferMode="StreamedRequest"
                 maxReceivedMessageSize="10000000"
                 maxBufferSize="1000"
                 />

      </webHttpBinding>

    </bindings>

  </system.serviceModel>

When I call the method through Android http request, I get status code 400 – Bad Request.
I have other methods on the same web service, which are working.
I just can’t figure out where the problem is.

  • 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-05-26T10:39:02+00:00Added an answer on May 26, 2026 at 10:39 am

    I setup a test server, based on the code you have posted above.

    I executed the following using Fiddler…

    POST http://localhost:3333/upload/step/filename HTTP/1.1

    User-Agent: Fiddler

    Host: localhost:3333

    Content-Length: 11

    <Foo></Foo>
    

    And on the server I tweaked your code a bit to something like this…

     public string FileUpload(string fileName, string step, Stream fileStream)
        {
            StreamReader reader = new StreamReader(fileStream);
            Console.WriteLine(reader.ReadToEnd());
            return "Done";
        }
    

    I had no issues.The code ran fine.

    Are you sure the URI template you have used is not getting conflicted with some other endpoint perhaps? (usually WebGet)

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

Sidebar

Related Questions

In my service contract I have: [OperationContract(Name = TreeViewData)] [WebInvoke(Method = POST, BodyStyle =
I have written the method contract: [OperationContract] [WebInvoke(Method = GET, ResponseFormat = WebMessageFormat.Xml, UriTemplate
I have the following operation contract method: [OperationContract] MyOutputMessageType DeleteVRequest(DeleteVRequest type); [MessageContract] public class
I have the following collection contract defined: [CollectionDataContract(Name = Centres)] public class Centres :
I have two tables: Contact (id,name) Link (id, contact_id, source_id) I have the following
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
Ok, I know I am missing something here. I have the following operation contract:
I am quite new to hibernate. I have got the following tables: Contract ContractID
I have the following method: public static DateTime SubQtrs( this DateTime dt, int qtrs
I have a WCF webservice that has the following service contract [ServiceContract(Namespace = http://example.org)]

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.