我有此错误:“意外的辅助令牌签名”。发生异常是因为发送请求时未签名,但响应已签名。似乎.net正在等待未签名的响应。
我正在尝试使用Using MTOM in a WCF custom encoder实现自定义编码器 我的代码如下:
// Convert string like " 00959" to just "00959"
Numero_de_produit = HtmlEntity.DeEntitize(Numero_de_produit).Trim();
在提到的博客参考中,我已经插入了此内容,以删除签名:
public static consultDocumentPortNameClient CreateDProxy(string url, string username, string password)
{
CustomBinding binding = new CustomBinding();
var security = TransportSecurityBindingElement.CreateUserNameOverTransportBindingElement();
security.IncludeTimestamp = false;
security.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic256;
security.MessageSecurityVersion = MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
security.EnableUnsecuredResponse = true;
security.SecurityHeaderLayout = SecurityHeaderLayout.Lax;
security.AllowInsecureTransport = true;
security.KeyEntropyMode = SecurityKeyEntropyMode.ServerEntropy;
//WSMessageEncoding.Text
var encoding = new MtomMessageEncodingBindingElement();
encoding.MessageVersion = MessageVersion.Soap11;
encoding.WriteEncoding = Encoding.UTF8;
var transport = new HttpsTransportBindingElement();
transport.MaxReceivedMessageSize = 2000000; // 2 megs
transport.RequireClientCertificate = false;
transport.AuthenticationScheme = System.Net.AuthenticationSchemes.Digest;
///***** this the portion of code where I put the
binding.Elements.Add(security);
binding.Elements.Add(encoding);
binding.Elements.Add(transport);
binding.Elements.Add(ReadMessage(varxxx, varxxx, varxxx))
该类包括以下方法:
public override Message ReadMessage(ArraySegment<byte> buffer, BufferManager bufferManager, string contentType)
{
//Convert the received buffer into a string
byte[] incomingResponse = buffer.Array;
incomingResponse = RemoveSignatures(incomingResponse);
........
我应该在哪里使用相应的参数来实现此方法(--- ReadMessage(varxxx,varxxx,varxxx)---)?
我是wcf的新手