Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am uploading a file via a webservice using REST and receiving an error message because I have multiple parameters in my POST WEBINVOKE.

this is error message...

For request in operation transferData to be a stream the operation must have a single parameter whose type is Stream.

I've read THOUSANDS of tutorials on this and I see other people have the same problem however I don't see a real solution for me.

any ideas on what



C#
 namespace EngineAppServiceV001
{
the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface IService1
{


    [OperationContract]
    [WebGet(UriTemplate = "/DoWork/{cid}",
      ResponseFormat = WebMessageFormat.Json,
      RequestFormat = WebMessageFormat.Json,
      BodyStyle = WebMessageBodyStyle.WrappedRequest)]
    DataSet DoWork(string cid);

    [OperationContract]
    [WebInvoke(Method = "POST",
        UriTemplate = "/UploadFile/{fileName}")]
    string transferData(string filename, Stream fileStream);


}



Here is my web.config


<bindings>
<basichttpbinding>
<binding maxbuffersize="2147483647" maxreceivedmessagesize="2147483647">
<readerquotas maxdepth="32" maxstringcontentlength="2147483647">
maxArrayLength="16348" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
</readerquotas></binding>
</basichttpbinding>
<webhttpbinding>
<binding name="ServiceWebBindingName" transfermode="Streamed" maxbuffersize="2147483647" maxreceivedmessagesize="2147483647">
<security mode="None"></security>
</binding>
</webhttpbinding>
</bindings>

<services>
<service name="EngineAppServiceV001.Service1" behaviorconfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="EngineAppServiceV001.IService1" behaviorconfiguration="web" />
</service>
</services>

<behaviors>

<servicebehaviors>
<behavior name="ServiceBehaviour">
<servicemetadata httpgetenabled="true" httpsgetenabled="true" />
<servicedebug includeexceptiondetailinfaults="true" />
</behavior>
</servicebehaviors>

<endpointbehaviors>
<behavior name="web">
<webhttp />
</behavior>
</endpointbehaviors>

</behaviors>
Posted
Updated 31-Jul-15 9:14am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900