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

  • Home
  • SEARCH
  • 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 6122507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:54:25+00:00 2026-05-23T15:54:25+00:00

I am developing a WCF web service that needs to be able to upload

  • 0

I am developing a WCF web service that needs to be able to upload files among other things.

Currently my method for adding a ‘floorplan’ item looks like:

[OperationContract]
[WebInvoke(Method = "GET",
    ResponseFormat = WebMessageFormat.Xml,
    BodyStyle = WebMessageBodyStyle.Wrapped,
    UriTemplate = "Floorplan?token={token}&floorplan={floorplan}")]
string XmlInputFloorplan(string token, string floorplan);

I need to alter it so that an image will be uploaded as a part of this call that can be used in a method like:

public static Guid AddFile(byte[] stream, string type);

In this case the byte[] is the content of the image. The resulting guid is then passed on to the data layer and the addition of the floorplan is finalized.

So I need to figure out two things:

1) How should I alter the XmlInputFloorplan interface method so that it also allows for an image as a parameter?
2) How do I consume the service after the alteration?

Thanks!

Here is how I solved it:

[OperationContract]
[WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Xml,
    BodyStyle = WebMessageBodyStyle.Wrapped,
    UriTemplate = "Floorplan")]
XmlDocument XmlInputFloorplan(Stream content);

Expects an input XML like:

<?xml version="1.0" encoding="us-ascii" ?>
<CreateFloorplanRequest>
  <Token></Token>
  <Floorplan></Floorplan>
  <Image></Image>
</CreateFloorplanRequest>

And the Image contains a base 64 encoded string that represents the image file which I convert to byte[] via:

XmlDocument doc = new XmlDocument();
doc.Load(content);
content.Close();

XmlElement body = doc.DocumentElement;
byte[] imageBytes = Convert.FromBase64String(body.ChildNodes[2].InnerText);

In order to allow for this I had to configure the Web.config like so:

<service behaviorConfiguration="someBehavior" name="blah.blahblah">
    <endpoint 
        address="DataEntry" 
        behaviorConfiguration="web" 
        binding="webHttpBinding" 
        bindingConfiguration="basicBinding" 
        contract="blah.IDataEntry" />
</service>

<bindings>
  <webHttpBinding>
    <binding name="basicBinding" maxReceivedMessageSize ="50000000"
        maxBufferPoolSize="50000000" >
      <readerQuotas maxDepth="500000000"
        maxArrayLength="500000000" maxBytesPerRead="500000000"
        maxNameTableCharCount="500000000" maxStringContentLength="500000000"/>
      <security mode="None"/>
    </binding>
  </webHttpBinding>
</bindings>
  • 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-23T15:54:27+00:00Added an answer on May 23, 2026 at 3:54 pm

    Your URI will look completely different – something like this (I’m having to make some guesses)

    [OperationContract]
    [WebInvoke(Method = "POST",
               ResponseFormat = WebMessageFormat.Xml,
               BodyStyle = WebMessageBodyStyle.Wrapped,
               UriTemplate = "Floorplan?type={type}&token={token}&floorplan={floorplan}")]
    Guid XmlInputFloorplan(string type, string token, string floorplan, Stream image);
    

    I’ve taken the liberty of changing the byte array to a Stream which gives you the option of streaming the image should it be large (but doesn’ t require streaming)

    To call this you can create a WebRequest with the correct Uri (including the type, token and floorplan) and perform a POST. Make the content type the right one for the format of the image (jpeg, png, etc) and get the request stream copying the image into it. Then call GetResponse on the WebRequest to make the HTTP request

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

Sidebar

Related Questions

I'm currently developing a WCF REST Web Service that will be running on Microsoft
I am currently developing an approval routing WCF service that will allow an user
I am developing a web application with multiple WCF service references. Currently, each time
I have a RESTful service that I am developing in WCF . I am
I am a newbie in WCF, currently I am developing a TCP WCF service
I am currently developing a service with wcf 4.0 (visual studio 2010 RC). When
I've been developing a WCF web service using .NET 3.5 with IIS7 and it
I'm developing a web service using NHibernate, WCF and Oracle 11g R1. The web
I am attempting to test a WCF web service I'm developing by accessing it
I'm developing a .NET 2.0 client application that needs to connect to a WCF

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.