operationcontract

Use parameter “params string[]” in WCF Rest endpoint

爱⌒轻易说出口 提交于 2019-12-08 01:10:39
问题 I would like to define an OperationContract, which I can pass any number of string parameters. The values should be interpreted as an array of string. Is there any possibility to use this type of parameter in an OperationContract and define this in the UriTemplate? [ServiceContract] public interface IRestService { [OperationContract] [WebGet(UriTemplate = "operations/{values}")] void Operations(params string[] values); } 回答1: You should not do this on a GET operation. GET operations support

WCF Post with Query String

时光毁灭记忆、已成空白 提交于 2019-12-06 08:09:42
问题 I am currently developing a Windows Service hosted WCF service. One of the methods has a URI which is set up to receive a callback from a payment provider. This is the interface contract... [OperationContract] [WebInvoke(UriTemplate = "3DSecureCallback?TrxId={id}", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare)] void ThreeDSecureCallBack(string id, Stream body); This issue I am having is that the 3rd party provider posts to our service. I have to provide a callback url to it. So we

WCF: Same Faultcontract on many methods

浪子不回头ぞ 提交于 2019-12-04 23:50: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? No, you need to do it on each and every method - WCF is rather picky and requires explicit settings pretty much for everything (which really is a good thing in the end, I am convinced). Marc

WCF Post with Query String

…衆ロ難τιáo~ 提交于 2019-12-04 12:26:05
I am currently developing a Windows Service hosted WCF service. One of the methods has a URI which is set up to receive a callback from a payment provider. This is the interface contract... [OperationContract] [WebInvoke(UriTemplate = "3DSecureCallback?TrxId={id}", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare)] void ThreeDSecureCallBack(string id, Stream body); This issue I am having is that the 3rd party provider posts to our service. I have to provide a callback url to it. So we can reconcile payments, we provide a URL with a query string parameter containing the transaction id.

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

穿精又带淫゛_ 提交于 2019-12-04 04:49:37
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 cannot be resolved.... There was no endpoint listening at ... , etc. I know that you can't have two

WCF contract changes that affect clients

荒凉一梦 提交于 2019-12-03 05:17:41
问题 I was curious if someone could outline which types of WCF contract (interface) changes on the server side would break a client trying to send in a message, and why. I believe WCF can handle certain discrepancies, but I'm not sure exactly what you can change safely, and what you can't. Add/remove parameters from an OperationContract? Add/remove/change the DataContract's serialized properties? Add/remove OperationContracts from a ServiceContract? A friend asked a similar question here: Does

WCF contract changes that affect clients

夙愿已清 提交于 2019-12-02 18:34:21
I was curious if someone could outline which types of WCF contract (interface) changes on the server side would break a client trying to send in a message, and why. I believe WCF can handle certain discrepancies, but I'm not sure exactly what you can change safely, and what you can't. Add/remove parameters from an OperationContract? Add/remove/change the DataContract's serialized properties? Add/remove OperationContracts from a ServiceContract? A friend asked a similar question here: Does adding a method to a WCF ServiceContract break existing clients? EDIT: As John Saunders pointed out,

WCF: is there an attribute to make parameters in the OperationContract required?

自闭症网瘾萝莉.ら 提交于 2019-11-29 10:22:27
I use [DataMember(IsRequired=true)] to make the DataContract properties required. There doesn't seem to be some IsRequired for the OperationContract parameters. How do I make them required and not allow null? The parameter in of OperationContract appears to be optional in SoapUI tool. Though this must never be optional or null. WCF Interface: [OperationContract] IsClientUpdateRequiredResult IsClientUpdateRequired(IsClientUpdateRequiredInput versie); ... [DataContract] public class IsClientUpdateRequiredInput { [DataMember(IsRequired=true)] public string clientName { get; set; } [DataMember

WCF OperationContract - which generic collection type should I expose?

霸气de小男生 提交于 2019-11-29 09:50:47
I have a WCF web service that has a method that returns a generic collection. Now, my question is: Should I expose it as ICollection<T> , List<T> , IList<T> , IEnumerable<T> or something else? I suppose that List<T> is out of the question since I want to avoid CA1002 errors , but the underlying type will be a List<T> . I am really interested in hearing your takes on this, preferably with a good explanation of why you think what you think. Thanks in advance Keep in mind that errors such as CA1002 are really meant to apply to libraries. A WCF service is not a library, it's an endpoint that's

WCF MessageContract Inheritance

送分小仙女□ 提交于 2019-11-28 13:42:52
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 BeginFindRequest(BaseMessage request, AsyncCallback callback, object asyncState); The problem that I am getting