wcf-rest

How to invoke WCF RESTful Service in Windows Service in asp.net?

主宰稳场 提交于 2019-12-11 07:12:09
问题 I have created below Operation Contract for POST Method in WCF RESTfule Service. IService1.cs:- [OperationContract] [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, UriTemplate = "/SaveCustomerPost", BodyStyle = WebMessageBodyStyle.Wrapped)] string SaveCustomerDetails(CustomerDetails objCustomerDetails); [DataContract] public class CustomerDetails { [DataMember] public string Name { get; set; } } Windows Service:- using (WebChannelFactory<ServiceReference1.IService1> cf =

Autofac + WCF REST 4.0

旧城冷巷雨未停 提交于 2019-12-11 06:51:30
问题 I am building a WCF 4.0 REST service and want to use Autofac as DI container. Apparently, I want to be able to call a parameterized constructor of the service class (service contract implementation), which accepts a bunch of interfaces to work with. Those interfaces are to be registered within Autofac container and I want them resolved and used when creating an instance of my service class (instead of calling not parameterized constructor, which is default). There is similar problem with MVC

Svcutil generates wrong Name property value in DataContractAttribute

爷,独闯天下 提交于 2019-12-11 04:39:42
问题 When I use svcutil.exe to generate a Customer class from the definition contained in the xsd file: <xs:schema ...> <xs:element name="customer" type="Customer" nillable="true" /> <xs:complexType name="Customer"> <xs:sequence> <xs:element name="id" type="xs:decimal" minOccurs="0" /> <xs:element name="first_name" type="xs:string" /> <xs:element name="last_name" type="xs:string" /> <xs:element name="phone" type="Phone" minOccurs="0" /> <xs:element name="email" type="Email" minOccurs="0" /> <xs

WCF Windows authentication issue with REST service

拈花ヽ惹草 提交于 2019-12-11 02:49:57
问题 I'm having some difficulty setting up a WCF service to run under Windows authentication. The service is only consumed via jQuery using ajax. IIS (version 6 on server 2003) is set to only allow Windows Authentication. web.config has the <authentication mode="Windows" /> tag. Here's the service section of the web.config: <system.serviceModel> <behaviors> <endpointBehaviors> <behavior name="AspNetAjaxBehavior"> <webHttp /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name=

Android gson deserialization into list

筅森魡賤 提交于 2019-12-11 02:42:56
问题 I am trying to parse a json string into a list, or arraylist. I have the following json response coming from a WCF RESTful service I created for an Android project [ { "Class": "Lorem", "Company": "Ipsum", "Id": "XXXX", "Name": "Avent" }, { "Class": "Consectetur", "Company": "Adipiscing", "Id": "YYYYY", "Name": "Nulla" } ] I've read several examples of parsing gson results on here, but I'm having difficulty enacting a container class as I've seen. I've gotten it to read a single result into a

Can WCF Restful service allow same method expose as WebGet and WebInvoke?

落花浮王杯 提交于 2019-12-10 15:44:47
问题 Can WCF Restful service allow same method expose as WebGet and WebInvoke like method overloading? Both method shoud be accessible from same URL. For Ex. [ServiceContract] public interface IWeChatBOService { [WebGet(UriTemplate = "WeChatService/{username}")] [OperationContract] string ProcessRequest(string MsgBody); [WebInvoke(Method = "POST", UriTemplate = "WeChatService/{username}")] [OperationContract] string ProcessRequest(string MsgBody); Is it possible to do with WCF Restful Service? 回答1

Restful service returns - There was an error checking start element of object of type System.Byte[]. Encountered unexpected character 'ÿ'

一个人想着一个人 提交于 2019-12-10 12:23:06
问题 So I am trying to send an image from the client side to the service. Service definition looks like this (implementation is nothing fancy and It doesn't reach there so excluding that code): [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "Image")] Stream Image(byte [] Image); The calling client looks like this: public static byte[] ImageToByte(Image img) { ImageConverter converter = new ImageConverter(); return (byte[])converter.ConvertTo(img, typeof(byte[])); } string uri =

Create a WCF Proxy for a Rest Web Service

不打扰是莪最后的温柔 提交于 2019-12-10 11:05:56
问题 I have a complex WCF Rest service which take multiple inputs and objects. I cannot simply call it by doing an HTTP POST in Fiddler because there is too much data to provide (I could, but it will take me forever). So I would like to do it in code using a proxy. Is there a way to generate a proxy for a .NET 4 WCF Rest Service? Otherwise, what do you propose to allow me to easily test the service? Thanks. 回答1: There's no standard way of creating a proxy for a WCF REST service (there's no WSDL

ServiceHost only supports class service types

落爺英雄遲暮 提交于 2019-12-10 01:04:49
问题 I have a service named WcfService2 (original i know) which has an IService.cs file with a public interface: namespace WcfService2 { [ServiceContract] public interface IService1 { [OperationContract] [WebGet(UriTemplate = "/{value}")] string GetData(string value); } } I then have my public class Service1.svc.cs file which returns a string for the value like so: namespace WcfService2 { public class Service1 : IService1 { public string GetData(string value) { return string.Format("You entered:

RESTful services: WCF versus ASP.NET MVC

做~自己de王妃 提交于 2019-12-09 08:21:46
问题 A very common approach to implementing RESTful services is by utilizing ASP.NET MVC to do so over WCF. ASP.NET MVC has excellent RESTful support by via flexible URL routing and flexible HTTP Method mapping to controller actions. WCF 4.0 now has excellent support for implementing RESTful service also using the same ASP.NET routing mechanism as ASP.NET MVC. Question What are your experiences working with either of the 2 approaches to create RESTful services and pros and cons encountered? 回答1: