wcf

Custom Element Names using the DataContractSerializer on a List of primitives

こ雲淡風輕ζ 提交于 2021-02-04 14:52:07
问题 I'm interested about the best way to go about setting custom element names when using List of primitives with the DataContractSerializer. Let's say I have the following class which contains a List of Strings as a DataMember. [DataContract] public class ClassName { [DataMember] public List<String> FieldName { get; set; } } By default, this serializes to the following: <ClassName xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <FieldName xmlns:a="http://schemas.microsoft.com/2003/10

RabbitMQ(四):RPC的实现

时光总嘲笑我的痴心妄想 提交于 2021-02-02 04:52:20
一、RPC   RPC(Remote Procedure Call)—远程过程调用,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议。有很多方式可以实现,譬如UNIX RPC、REST API、WCF和SOAP。这些传统的RPC实现方法有共同之处:那就是客户端和服务器端紧密相连,客户端直接连接上服务器,发送一个请求,然后就停下来等待服务器的应答。   这种点对点的性质模式有很多好处,它使得在小范围内的拓扑变得简单。但是当有众多服务器的时候,客户端如何发现在那台服务器上可以找到其他想要的服务就变的麻烦,SOAP和大多数的企业RPC已经采用复杂的补充协议和服务目录,但也带来了额外的复杂度和众多故障点。   但是,用RabbitMQ来实现RPC可以无需关心由那台服务器来处理,也不必担心服务器奔溃,只需要简单的发送消息,然后等待响应即可。一般接触RabbitMQ的都是用发后即忘模型,用于发送邮件等通知或者处理其他并行处理事件,也就是AMQP的消息是单向的。如何才能让服务器将处理结果返回给原始的客户端呢? 二、消息应答和私有队列   RabbitMQ有一个优雅的解决方案:使用消息来发回应答。在每个AMQP消息头里有个字段 reply_to .消息的生产者可以通过该字段来确定队列的名称,并监听应答队列等待应答。然后接收消息的RPC服务器能偶检查reply_to字段

how to access EF navigation properties via WCF SOAP service?

点点圈 提交于 2021-01-29 22:22:50
问题 I am struggling with this WCF error for some time now without any luck. Basically I am tying to fetch an Entity Poco with Navigation Properties and connected objects via WCF Services. My EF v6 code successfully get the poco with all the related entities from the DB Poco debug view but as i try to access this Entity via WCF service , i see the following error - An error occurred while receiving the HTTP response to http://localhost:8734/Design_Time_Addresses/BusinessLogicServicesLayer

how to access EF navigation properties via WCF SOAP service?

拜拜、爱过 提交于 2021-01-29 22:08:16
问题 I am struggling with this WCF error for some time now without any luck. Basically I am tying to fetch an Entity Poco with Navigation Properties and connected objects via WCF Services. My EF v6 code successfully get the poco with all the related entities from the DB Poco debug view but as i try to access this Entity via WCF service , i see the following error - An error occurred while receiving the HTTP response to http://localhost:8734/Design_Time_Addresses/BusinessLogicServicesLayer

Provide exceptions for wcf webhttpbinding

被刻印的时光 ゝ 提交于 2021-01-29 19:09:17
问题 I have to change a binding for wcf webservices from tcpbinding to webhttpbinding with basic authentication and ssl. Webservices are self hosted in a console application and in a windows service for production version. Some of local services are with named pipe binding, just if a service call another service. All works perfectly but not the global error manager (a class that implement IErrorHandler interface) Some of DAL or business methods throw an exception with a custom message and this

Can we use simple injector for dependency injection in wcf services and How?

不问归期 提交于 2021-01-29 15:47:14
问题 Can we use simple injector for dependency injection in wcf services 回答1: We can use simple injector for dependency injection in wcf services.Here is my demo. After installing this NuGet package, it must be initialized in the start-up path of the application by calling the SimpleInjectorServiceHostFactory.SetContainer method: protected void Application_Start(object sender, EventArgs e) { var container = new Container(); container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();

Provide exceptions for wcf webhttpbinding

一曲冷凌霜 提交于 2021-01-29 14:16:27
问题 I have to change a binding for wcf webservices from tcpbinding to webhttpbinding with basic authentication and ssl. Webservices are self hosted in a console application and in a windows service for production version. Some of local services are with named pipe binding, just if a service call another service. All works perfectly but not the global error manager (a class that implement IErrorHandler interface) Some of DAL or business methods throw an exception with a custom message and this

How to upload image of various type (jpg/png/gif) to the server through Stream using WCF web API

会有一股神秘感。 提交于 2021-01-29 12:58:40
问题 For some reason, Im using WCF for webAPIs..I have been using WCF for few days now. On the hunt to find the code to upload image to the server I found many answers and solutions like: Could not upload Image to WCF Rest service Uploading image as attachment in RESTful WCF Service Uploading an image using WCF RESTFul service full working example the above (full woking) example is working for me..accept for the part that it accepts only jpeg images. Since im using Postman to hit on the request,

How to Implement custom authentication in WCF service

眉间皱痕 提交于 2021-01-29 11:23:12
问题 I would like to create WCF restful service for mobile application with custom authentication. First request should be login, specially client sending username, password and getting access token. Then all other requests should be check access token. Also for authentication I would like to use asp.net membership provider in other words to use Forms based authentication. 回答1: At first, we should configure the Asp.net SQL membership Provider. Then we should use Username/password security mode so

enable CORS using WCF

僤鯓⒐⒋嵵緔 提交于 2021-01-29 10:11:36
问题 I'm trying to enable CORS using WCF. But I get Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 404. This is my Global.asax protected void Application_BeginRequest(object sender, EventArgs e) { HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*"); if (HttpContext.Current.Request