wcf-rest

How does WCF WebApi map a request URI to the appropriate service type / operation?

徘徊边缘 提交于 2019-12-06 12:07:05
问题 How does WCF REST (and WCF WebApi) map a Uri to the correct service endpoint? Within the context of WCF WebApi Preview 4: Inside a custom delegating channel, I would like to find the associated route prefix or service Type based on the incoming HttpRequestMessage.RequestUri. So for instance, RouteTable.Routes.MapServiceRoute<ManagersResource>("employees/managers", config); RouteTable.Routes.MapServiceRoute<EmployeesResource>("employees", config); Say a request comes in for http://server

Something like an operation filter in WCF REST?

北城以北 提交于 2019-12-06 09:28:53
问题 I am looking for something like the AuthorizeAttribute in MVC, something I can use like this: [WebGet(UriTemplate = "data/{spageNumber}")] [WebCache(CacheProfileName = "SampleProfile")] [WcfAuthorize] public IEnumerable<SampleItem> GetCollection(String spageNumber) { Int32 itemsPerPage = 10; Int32 pageNumber = Int32.Parse(spageNumber); return Enumerable.Range(pageNumber * itemsPerPage, itemsPerPage) .Select(i => SampleItem.Create(i)); } That WcfAuthorizeAttribute , will try to authenticate

how to send custom object to WCF REST Service in browser based url [duplicate]

泄露秘密 提交于 2019-12-06 07:08:02
问题 This question already has answers here : Passing complex objects into a WCF Rest Service (2 answers) Closed 5 years ago . i have a serializable entity class of employee public class Emp { public int Id{get; set;} public string Name{get;set;} } i want to send object of this class to WCF REST Services from browser to test my add method which is given below [WebInvoke(Method = "POST", UriTemplate = "Employee/")] [OperationContract] string SaveEmployee(Emp Employee); can anyone please tell me how

How to tweak default JSON serializer in WCF REST

柔情痞子 提交于 2019-12-06 05:07:56
问题 WCF REST service works great in a way that it will reply/accept JSON or XML depending on header. I want to tweak built-in JSON serializer a little so it encodes/decodes Byte[] little different. More specifically, I want to use Base64 for that. Is that any pointers/samples where I can set custom type serializer that will affect whole service? 回答1: The post at http://blogs.msdn.com/b/carlosfigueira/archive/2011/05/03/wcf-extensibility-message-formatters.aspx shows how to replace the default

Test Client for testing WCF Rest services or just use browser?

人盡茶涼 提交于 2019-12-06 04:51:04
I have written my first rest services and currently i am testing them in a browser. Is there a test client or some sort that provides additional features or is this the normal way of testing i.e. in IE, Firefox etc? I use Fiddler. Browsers are a real pain to try and test with. You may want to consider testing them through a unit testing framework instead of through the browsers. E.g. NUnit or - depending on your Visual Studio edition - MS Test might be options. You may be able to avoid the WCF protocol overhead and talk straight to the service implementations, unless you specifically want to

Exposing meta data for a WCF 4.0 Rest Template Service

梦想与她 提交于 2019-12-05 21:12:06
Probably missing something very basic. I created a WCF 4.0 Rest Service. It works no problems when I'm hitting the url from a browser and I'm getting back what I want. But now I want to use that service from a client mvc application (it will also be used by other non .net platforms which is why it's a rest service in the first place). Problem is how do I get a service reference to it so I can start to use it in my c# code? With the new minimal WCF .net 4 config approach and no interface for the service contract, I don't know how to specify a mex endpoint. Ultimately I don't want a mex endpoint

Difference between PUT and POST using WCF REST

前提是你 提交于 2019-12-05 11:42:38
I have tried to implement a REST WCF in order to explore difference between PUT and POST verb. I have uploded a file in a location using the service. The service implementation is as folowing: [OperationContract] [WebInvoke(UriTemplate = "/UploadFile", Method = "POST")] void UploadFile(Stream fileContents); public void UploadFile(Stream fileContents) { byte[] buffer = new byte[32768]; MemoryStream ms = new MemoryStream(); int bytesRead, totalBytesRead = 0; do { bytesRead = fileContents.Read(buffer, 0, buffer.Length); totalBytesRead += bytesRead; ms.Write(buffer, 0, bytesRead); } while

Customize the WebHttp Help Output in WCF

我的梦境 提交于 2019-12-05 02:52:05
For a service with webHttpBinding and helpEnabled="true", the help information is getting generated properly. Was wondering if it is possible to control the output somehow. Below are the changes I would like to make. Remove the JSON help as the service doesn't support JSON output. Having it there might be confusing to users. At least, have a way to output a note saying JSON is not supported. For the example replies shown, use a better example than "String content" where actual value samples can be specified. Would be good if I can supply the object that is used for being serialized as example.

Sharing the same port for WCF REST and ASP.NET Web API

僤鯓⒐⒋嵵緔 提交于 2019-12-05 01:48:54
问题 I've an existing JSON based service implemented using WCF webhttpbinding. This service is hosted in Windows service. We've implemented SSL as well. Now I'm planning to create new JSON based services using ASP.NET Web API which should be hosted in windows service. But the problem is the clients are behind firewalls and they cannot expose many ports to world and so I've to reuse the already opened port . I'm aware this is not possible straight. But is there any workaround we could use the same

Render an MVC3 action to a string from a WCF REST service method

廉价感情. 提交于 2019-12-04 20:33:06
I have a WCF REST service that takes some parameters and sends an email. The template for the email is an MVC3 action. Essentially I want to render that action to a string. If it were an ASP.NET WebForm, I could simply use Server.Execute(path, stringWriter, false) . However when I plug in the path to my action, I get Error executing child request . I have full access to HttpContext from my service ( AspNetCompatibilityRequirementsMode.Allowed ). I know there are other answers out there for rendering actions to strings from within the context of a controller. How do I do this when I'm outside