c# - ASP Rest Services with Stream -
i trying building rest service stream input want save in file on server. problem when run service 'endpoint not found'
i using vs 2010 .net 4.0
my service model under
<services> <service name="wcfservice1.testservice" behaviorconfiguration="servicebehaviour"> <endpoint address="" binding="webhttpbinding" contract="wcfservice1.itestservice" behaviorconfiguration="web" /> </service> </services> <behaviors> <servicebehaviors> <behavior name="servicebehaviour"> <servicemetadata httpgetenabled="true" /> <servicedebug includeexceptiondetailinfaults="true" /> </behavior> </servicebehaviors> <endpointbehaviors> <behavior name="web"> <webhttp/> </behavior> </endpointbehaviors> </behaviors>
the code simple @ stage. service code
namespace wcfservice1 { // note: can use "rename" command on "refactor" menu change interface name "iservice1" in both code , config file together. [servicecontract] public interface itestservice { [operationcontract] [webinvoke(method = "post", uritemplate = "uploadfile/{filename}", bodystyle = webmessagebodystyle.bare)] stream uploadfile(string filename, stream filecontents); } }
function implementation
public stream uploadfile(string filename, stream filecontents) { //save file var sr = new streamreader(filecontents); string text = sr.readtoend(); return new system.io.memorystream(encoding.utf8.getbytes("hello world! " + text + filename)); }
svc file
<%@ servicehost language="c#" debug="true" service="wcfservice1.testservice" codebehind="testservice.svc.cs" factory="system.servicemodel.activation.webservicehostfactory"%>
what doing wrong?
Comments
Post a Comment