wcf

How can I add a namespace to soap envelope in c#

不问归期 提交于 2020-06-16 00:15:50
问题 I want to add a namespace setting to my soap envelope. I would like to change it in the BeforeSendRequest in an IClientMessageInspector or you have a more elegant way. For example <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"> <s:Header> <wsa:To xmlns="http://www.w3.org/2005/08/addressing">ws://xxx/V1</wsa:To> ... </s:Header> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> ... </s:Body> </s:Envelope> to <s:Envelope

How to serialize a Func<int, int> (or even a general delegate) type field with DataContract/DataMember in WCF

冷暖自知 提交于 2020-06-13 19:32:25
问题 I am trying to serialize a Func<int, int> field marked with [DataMember] , of a class marked with [DataContract] , whose target or Lambda expression definition is also part of the contract or could even be in the class itself. I am using a custom DataContractResolver which works perfectly well when I unmark the Func field but when I mark it, it does not resolve a System.DelegateSerializationHolder type needed for the serialization. I tried to add this type to my custom DataContractResolver

Using Connection: Close in webserver SOAP requests

夙愿已清 提交于 2020-05-28 04:45:49
问题 The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. We're getting this exception frequently when using .Net 4.0 web service client to communicate with an ONVIF network device. Looking at the packet captures, this seems to be a device that is non compliant with the HTTP spec and closing a connection after sending the response, against the HTTP/1.1 default of keeping it alive. This results in the client (WCF) trying to reuse the

Using Connection: Close in webserver SOAP requests

╄→尐↘猪︶ㄣ 提交于 2020-05-28 04:45:02
问题 The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. We're getting this exception frequently when using .Net 4.0 web service client to communicate with an ONVIF network device. Looking at the packet captures, this seems to be a device that is non compliant with the HTTP spec and closing a connection after sending the response, against the HTTP/1.1 default of keeping it alive. This results in the client (WCF) trying to reuse the

SOAP WCF add Signature and BinarySecurityToken to header

╄→гoц情女王★ 提交于 2020-05-17 07:06:28
问题 The bounty expires in 7 days . Answers to this question are eligible for a +100 reputation bounty. Cieja is looking for an answer from a reputable source . I need something more, Signature must be within a Security tag inside Header tag, with a BinarySecurityToken element Just like: <soapenv:Header> <!-- extrac of the example file --> <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu=" http://docs

Enable BlueTooth programmatically using C#.net (not UWP)

我只是一个虾纸丫 提交于 2020-05-14 12:36:05
问题 How to Enable BlueTooth programmatically using C#.net. I know there are some APIs in UWP, but I am working on WPF. So dont want get into integrating with UWP code. Please let me know if there is way in C#.net or WPF or Winforms? 来源: https://stackoverflow.com/questions/54555202/enable-bluetooth-programmatically-using-c-net-not-uwp

setting cookies within a wcf service

☆樱花仙子☆ 提交于 2020-05-14 09:01:32
问题 I have a asp mvc application consuming wcf rest services (all on the same box). For authentication calls, I am trying to set cookies inside a wcf rest service. Code on the client side - HttpResponseMessage resp; HttpClient client = new HttpClient("http://localhost/auth/login/"); resp = client.Get(); In the webservice I just use FormsAuthentication to set an authcookie. HttpCookie authCookie = FormsAuthentication.GetAuthCookie("foo", false); HttpContext.Current.Response.Cookies.Add(authCookie)

DTOs. Properties or fields?

为君一笑 提交于 2020-05-12 11:19:39
问题 I need to create some DTO classes to transport our business objects across WCF. Since these are just bags of data with no functionality, is there any reason I can't just use fields, or is there some good reason to expose them properly as properties? //fields [DataContract] class CustomerDTO { [DataMember] public int Id; [DataMember] public string Name; } //or properties? [DataContract] class CustomerDTO { [DataMember] public int Id { get; set; } [DataMember] public string Name { get; set; } }

C# 基础连接已经关闭: 未能为 SSL/TLS 安全通道建立信任关系。

柔情痞子 提交于 2020-05-08 05:21:06
今天写程序的时候调用到一个第三方的DLL文件,本机调试一切都正常,但是程序不是到服务器以后一直提示一个BUG:"基础连接已经关闭: 未能为SSL/TLS 安全通道建立信任关系"。 后来把DLL文件进行反编译,发现是在获得请求的时候出错了。 引用  WebResponse response = WebRequest.Create("https://……").GetResponse(); 定义一个类,来对远程X.509证书的验证,进行处理,返回为true.我们要自己定义一个类,然后在客户单调用WCF服务之前,执行一次即可。代码如下: public static class Util { /// <summary> /// Sets the cert policy. /// </summary> public static void SetCertificatePolicy() { ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidate; } /// <summary> /// Remotes the certificate validate. /// </summary> private static bool RemoteCertificateValidate(

【C/S】FIPS安全验证问题

杀马特。学长 韩版系。学妹 提交于 2020-05-06 10:31:01
  现如今的开发第一考虑的都是B/S架构或是移动端为主,传统的PC C/S已经相对于少些了,去年年初的时候还信誓旦旦的现在是Web为主,我才不要去写什么WPF,谁料人算不如天算。现如今又重操C/S了,虽没多久,但是却踩到了很多的坑。此类随笔记录一下最近做C/S遇到的问题。   C/S与B/S从大体上看只是数据的展现形式不一样,C/S繁琐的安装、频繁的更新对于用户来说是很烦人的。但是C/S带来的优点也是数不胜数的。C/S客户端对用户来讲有一种专属定制的感觉,并且从效率上也会比B/S高一些。但是Client端的安装、部署、升级、版本控制也是非常的麻烦。   我所做的C/S其实只是一个内嵌浏览器的壳子,实质上还是B/S。所以承受着C/S与B/S两者的所有优缺点。先说第一个坑,我所采用的是WCF进行通讯,数据是通过AES加密的,在大部分的用户机上都是没有问题的,但是有一天某客户无法登陆了,后查看日志发现用户开启了FIPS验证。因为AES加密方式不符合FIPS标准,所以禁止了请求。   起初的解决方案为关闭FIPS验证(通过:CMD -> gpedit.msc -> 计算机配置 -> Windows设置 -> 安全设置 -> 本地策略 -> 安全选项 -> 系统加密:将FIPS兼容算法用于加密、哈希和签名 -> 禁用),但是不是每一个用户都可以听懂的,所以不能从各个端去设置