operationcontract

In WCF can I have a wildcard character in a literal segment of my UriTemplate?

孤人 提交于 2021-01-27 17:11:09
问题 I am authoring a RESTful WCF service using .Net 4.0. I want the following two URLS: /root/document/{ids}?fields={fields} /root/externaldocument/{ids}?fields={fields} to map to the same interface member: Documents GetDocuments(string ids, string fields) I have tried putting a wildcard into a literal URL segment: [OperationContract] [WebGet(UriTemplate = "/root/*document/{ids}?fields={fields}")] Documents GetDocuments(string ids, string fields) However, this is not valid and I get the following

What is the use of “AsyncPattern” property of “OperationContractAttribute” + wcf?

空扰寡人 提交于 2020-01-16 07:04:26
问题 Thus for used ajax enabled wcf services to get records from DB and display it in client without using AsyncPattern property of OperationContractAttribute .... When should i consider AsyncPattern property? Sample of my operationcontract methods, [OperationContract] public string GetDesignationData() { DataSet dt = GetDesignationViewData(); return GetJSONString(dt.Tables[0]); } public string GetJSONString(DataTable Dt) { string[] StrDc = new string[Dt.Columns.Count]; string HeadStr = string

Getting Gibberish instead of Hello World from a service with webHttpBinding

一世执手 提交于 2019-12-25 03:21:54
问题 Here is a trivial example that is supposed to return "Hello World" string. However, a browser displays something like SGVsbG8gV29ybGQ= . Which is the right way to return plain text from an oldskul-style service? please know that: I can't return a string: three Unicode characters will be automatically prepended and the legacy HTTP client won't be able to interoperate. I could return a Message , but still must keep parsing functionality to extract the data variable. Mixing Message and int types

WCF Generics - Why do DataContract and CollectionDataContract allow formatted naming, but not DataMember, OperationContract or ServiceContract?

北城余情 提交于 2019-12-24 01:09:18
问题 Basically as the title says: [DataContract(Name = "{0}Item")] //This will format properly public class GenericItem<T> { [DataMember(Name = "The{0}")] //This will NOT format properly public T TheItem { get; set; } } [CollectionDataContract(Name = "{0}Items")] //This will format properly public SpecialCollection<T> : Collection<T> { } [ServiceContract(Name = "{0}Service")] //This will NOT format properly public interface IGenericService<T> { [OperationContract(Name = "Get{0}")] //This will NOT

WCF: Same Faultcontract on many methods

喜夏-厌秋 提交于 2019-12-22 02:03:27
问题 Take for example a project with 10 services and 20 methods on each service. All services inherit from a base services which has a security check. The first thing each method does is to make a call to the security check. This throws a security exception if there is a problem. Question is: Do I need to specify a FaultContract on each method (OperationContract), or can I do it once in a central definition? 回答1: No, you need to do it on each and every method - WCF is rather picky and requires

WCF service method unavailable in WCF Test Client because it uses type

泪湿孤枕 提交于 2019-12-18 11:50:11
问题 I am trying to use the WCF Test Client to test a WCF service I have built. The service has one method "SubmitRequest". [OperationContract] Response SubmitRequest(Request request); When I load up the WCF Test Client, the method is grayed out with the message "This operation is not supported in the WCF Test Client because it uses type WcfLibrary.Objects.Request Below is the type definition, does anyone see anything wrong? [DataContract] public class Request { [DataMember] public string

WCF MessageContract Inheritance

做~自己de王妃 提交于 2019-12-17 21:03:35
问题 I am fairly new to WCF and just have a question on how to correctly get MessageContract inheritance working. A simplified version of my setup is as follows - a "base" message type, and then another "test" message which inherits from it. [MessageContract] public abstract class BaseMessage { } [MessageContract] public class TestMessage : BaseMessage { } I then have an asynchronous OperationContract on a ServiceContract defined as: [OperationContract(AsyncPattern = true)] IAsyncResult

how to apply OperationContract to all methods in interface

∥☆過路亽.° 提交于 2019-12-12 17:22:40
问题 Im creating a service contract in my wcf application and it contains a lot of methods. I find it very annoying to write an OperationContract attribute to all of them. Is there any simple way how to say "every method in my ServiceContract interface is an OperationContract " ? thank you 回答1: Yes, you can use AOP framework for that. E.g. with PostSharp: [Serializable] public sealed class AutoServiceContractAttribute : TypeLevelAspect, IAspectProvider { // This method is called at build time and

How to specify a parameter of an OperationContract as required

一笑奈何 提交于 2019-12-10 13:28:38
问题 I wonder how I can specify a parameter of an OperationContract method in WCF as required so that the generated xsd contains minOccurs="1" instead of minOccurs="0". Example: [ServiceContract(Namespace = "http://myUrl.com")] public interface IMyWebService { [OperationContract] string DoSomething(string param1, string param2, string param3); } generates this xsd: <xs:element name="DoSomething"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="param1" nillable="true" type="xs:string

WCF class implementing two operation contracts in different service contracts with same name

流过昼夜 提交于 2019-12-09 16:00:57
问题 I have declared two service contracts as follows: [ServiceContract] public interface IContract1 { [OperationContract] double Add(int ip); } [ServiceContract] public interface IContract2 { [OperationContract] double Add(double ip); } I have a class which implements these two contracts. I have created two endpoints for both contracts. But I'm not able to access the service from client code. It displays a big error when I try to update the service reference as: Metadata contains an error that