wcf-rest

Restful WCF POST issue with application/json content type request

坚强是说给别人听的谎言 提交于 2019-12-04 18:19:50
I've configured a RESTful WCF with the following POST "operation": [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "/Test", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json)] void PostTest(Stream stream); In my web.config, I've configured the following: <service name="MyTest.TestSvc" behaviorConfiguration="MyTest.TestBehavior" > <endpoint address="" behaviorConfiguration="MyBehavior" binding="webHttpBinding" contract="MyTest.ITestSvc"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> <endpointBehaviors>

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

天大地大妈咪最大 提交于 2019-12-04 17:20:57
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/employees/John How does WCF map this to the correct endpoint? By the time the ResourceFactoryProvider has

Something like an operation filter in WCF REST?

故事扮演 提交于 2019-12-04 16:45:46
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 the user with FormsAuthentication, and set the context's IPrincipal, or return a HTTP 401 Unauthorized. I

How to create query expression for Odata for get by Id

守給你的承諾、 提交于 2019-12-04 13:14:56
I have created an OData service and now I am trying to consume this service at client side. I wants to create an expression such as for the below url in the c# query expression- http://odata.org/Product-Service/Product(150) The above url is working fine in browsers but I want to create query expression in the C# for the above url. Any help would be greatly appreciable. You could use a DataServiceContext + DataServiceQuery in System.Data.Services.Client to hit the Url. Remember no query is executed until the call to First() due to lazy loading. var context = new DataServiceContext(new Uri("http

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

﹥>﹥吖頭↗ 提交于 2019-12-04 12:45:48
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 to send custom object to WCF REST Service in browser based url If you want to send the complex object

Sending Post request to RESTful WCF with json

情到浓时终转凉″ 提交于 2019-12-04 11:51:04
问题 I have tried every combination to send a request to send a POST request to RESTful WCF from jQuery. Can someone imitate and make it working. Code is here : http://pastebin.com/Ua97919C I am working with WCF from past 2 years, but every time i send a POST request it makes me struggle a lot. I am struggling to make it work from past 4 days and gone through atleast 35-40 posts. Eventually, this request would be sent from iPhone to WCF. When i check it with Fiddler the error mostly is: *The

Get Client IP address using WCF 4.5 RemoteEndpointMessageProperty in load balancing situation

ぐ巨炮叔叔 提交于 2019-12-04 08:47:15
I have hosted WCF 4.5 Restful service in IIS and I am trying to use RemoteEndpointMessageProperty to get the IP address of the client who consumes the service. Code 1: private string GetClientIP() { OperationContext context = OperationContext.Current; MessageProperties prop = context.IncomingMessageProperties; RemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; string ip = endpoint.Address; return ip; } Code 2: private string GetClientIP() { string retIp = string.Empty; OperationContext context = OperationContext.Current;

WCF Error : Relative end point addresses

雨燕双飞 提交于 2019-12-04 02:01:23
Um quite new to WCF . I think I have messed up a bit. So this is what I did so far and I ve hosted my WCF service in IIS First the Contracts using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; using YangkeeServer.dto; namespace YangkeeServer { public class Service1 : IService1 { [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "single")] public YangkeeTrailerDTO getTrailor() { return new YangkeeTrailerDTO() { loanFrom = "heaven" }; }

wcf REST Services and JQuery Ajax Post: Method not allowed

ε祈祈猫儿з 提交于 2019-12-03 13:50:41
问题 Anyone knows what's wrong with this? I cant get the json response from my wcf rest service. Jquery $.ajax({ type: 'POST', url: "http://localhost:8090/UserService/ValidateUser", data: {username: 'newuser', password: 'pwd'}, contentType: "application/json; charset=utf-8", success: function(msg) { alert(msg); }, error: function(xhr, ajaxOptions, thrownError) { alert('error'); } }); Service [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

How to make user login from only one device at a time

不打扰是莪最后的温柔 提交于 2019-12-03 12:55:29
问题 I have a RestAPI which when hit authenticate the user. This api is exposed to android and ios developers they hit this api to allow user to login to our app My requirement is this.1) If user has cell phone say abc phone with IMEI "abc1234". He logs in from this phone. Now if he tries to log in from his 2nd phone than he should not be allowed to login from 2nd phone. He should first log out from abc device. now there is few complications 1) if user is logged from abc. With out loging out he