trying implement a Custom Encoder in WCF
up vote
0
down vote
favorite
I have this error: "the auxiliary token signatures that are not expected". The exception occurs because the request is sent without signing , but the response is signed. It seems that .net is waiting for an unsigned response.
I'm Trying to implement a custom Encoder using the Using MTOM in a WCF custom encoder
my code is as follows:
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))
in the mentioned blog reference I've insert this, that remove the signature:
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);
........
and that class include the follow method:
private byte RemoveSignatures(byte stream)
{
string stream2 = Encoding.UTF8.GetString(stream);
stream2 = stream2.Replace("", "");
Regex x = new Regex("(\<SOAP-ENV:Header\>)(.*?)(\</SOAP-ENV:Header\>)");
string repl = "";
stream2 = x.Replace(stream2, "$1" + repl + "$3");
byte streamNuevo = Encoding.ASCII.GetBytes(stream2);
return streamNuevo;
}
where should I implement this method (--- ReadMessage (varxxx, varxxx, varxxx) ---) with the respective parameters?
I'm a newbie with wcf
c# xml web-services wcf
add a comment |
up vote
0
down vote
favorite
I have this error: "the auxiliary token signatures that are not expected". The exception occurs because the request is sent without signing , but the response is signed. It seems that .net is waiting for an unsigned response.
I'm Trying to implement a custom Encoder using the Using MTOM in a WCF custom encoder
my code is as follows:
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))
in the mentioned blog reference I've insert this, that remove the signature:
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);
........
and that class include the follow method:
private byte RemoveSignatures(byte stream)
{
string stream2 = Encoding.UTF8.GetString(stream);
stream2 = stream2.Replace("", "");
Regex x = new Regex("(\<SOAP-ENV:Header\>)(.*?)(\</SOAP-ENV:Header\>)");
string repl = "";
stream2 = x.Replace(stream2, "$1" + repl + "$3");
byte streamNuevo = Encoding.ASCII.GetBytes(stream2);
return streamNuevo;
}
where should I implement this method (--- ReadMessage (varxxx, varxxx, varxxx) ---) with the respective parameters?
I'm a newbie with wcf
c# xml web-services wcf
Did you use a sniffer like wireshark or fiddler to see what response you actually got. Check the response statues to see if you got a 200 DONE or something else. Also make sure you download the entire code in the link "here" which is a zip file with the entire project. You may also be timing out with no response which indicates your request was bad.
– jdweng
Nov 22 at 20:57
@jdweng yep! I did! i used fiddler and the response was 200 well done! but In a try catch, writes me in a logger "the auxiliary token signatures that are not expected" it seems that dot net is waiting for an unsigned response. My idea is to eliminate the signature in the response; so what I want is.. that, it does not write that kind of error!
– ger
Nov 22 at 21:09
Once you get a 200 DONE there is no more data. If Net is waiting then maybe it is expecting http 1.1 (chunk mode) instead of 1.0 (stream mode). You are looking for security which is https but it looks like you are getting non secure http.
– jdweng
Nov 22 at 21:43
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have this error: "the auxiliary token signatures that are not expected". The exception occurs because the request is sent without signing , but the response is signed. It seems that .net is waiting for an unsigned response.
I'm Trying to implement a custom Encoder using the Using MTOM in a WCF custom encoder
my code is as follows:
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))
in the mentioned blog reference I've insert this, that remove the signature:
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);
........
and that class include the follow method:
private byte RemoveSignatures(byte stream)
{
string stream2 = Encoding.UTF8.GetString(stream);
stream2 = stream2.Replace("", "");
Regex x = new Regex("(\<SOAP-ENV:Header\>)(.*?)(\</SOAP-ENV:Header\>)");
string repl = "";
stream2 = x.Replace(stream2, "$1" + repl + "$3");
byte streamNuevo = Encoding.ASCII.GetBytes(stream2);
return streamNuevo;
}
where should I implement this method (--- ReadMessage (varxxx, varxxx, varxxx) ---) with the respective parameters?
I'm a newbie with wcf
c# xml web-services wcf
I have this error: "the auxiliary token signatures that are not expected". The exception occurs because the request is sent without signing , but the response is signed. It seems that .net is waiting for an unsigned response.
I'm Trying to implement a custom Encoder using the Using MTOM in a WCF custom encoder
my code is as follows:
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))
in the mentioned blog reference I've insert this, that remove the signature:
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);
........
and that class include the follow method:
private byte RemoveSignatures(byte stream)
{
string stream2 = Encoding.UTF8.GetString(stream);
stream2 = stream2.Replace("", "");
Regex x = new Regex("(\<SOAP-ENV:Header\>)(.*?)(\</SOAP-ENV:Header\>)");
string repl = "";
stream2 = x.Replace(stream2, "$1" + repl + "$3");
byte streamNuevo = Encoding.ASCII.GetBytes(stream2);
return streamNuevo;
}
where should I implement this method (--- ReadMessage (varxxx, varxxx, varxxx) ---) with the respective parameters?
I'm a newbie with wcf
c# xml web-services wcf
c# xml web-services wcf
asked Nov 22 at 17:09
ger
228212
228212
Did you use a sniffer like wireshark or fiddler to see what response you actually got. Check the response statues to see if you got a 200 DONE or something else. Also make sure you download the entire code in the link "here" which is a zip file with the entire project. You may also be timing out with no response which indicates your request was bad.
– jdweng
Nov 22 at 20:57
@jdweng yep! I did! i used fiddler and the response was 200 well done! but In a try catch, writes me in a logger "the auxiliary token signatures that are not expected" it seems that dot net is waiting for an unsigned response. My idea is to eliminate the signature in the response; so what I want is.. that, it does not write that kind of error!
– ger
Nov 22 at 21:09
Once you get a 200 DONE there is no more data. If Net is waiting then maybe it is expecting http 1.1 (chunk mode) instead of 1.0 (stream mode). You are looking for security which is https but it looks like you are getting non secure http.
– jdweng
Nov 22 at 21:43
add a comment |
Did you use a sniffer like wireshark or fiddler to see what response you actually got. Check the response statues to see if you got a 200 DONE or something else. Also make sure you download the entire code in the link "here" which is a zip file with the entire project. You may also be timing out with no response which indicates your request was bad.
– jdweng
Nov 22 at 20:57
@jdweng yep! I did! i used fiddler and the response was 200 well done! but In a try catch, writes me in a logger "the auxiliary token signatures that are not expected" it seems that dot net is waiting for an unsigned response. My idea is to eliminate the signature in the response; so what I want is.. that, it does not write that kind of error!
– ger
Nov 22 at 21:09
Once you get a 200 DONE there is no more data. If Net is waiting then maybe it is expecting http 1.1 (chunk mode) instead of 1.0 (stream mode). You are looking for security which is https but it looks like you are getting non secure http.
– jdweng
Nov 22 at 21:43
Did you use a sniffer like wireshark or fiddler to see what response you actually got. Check the response statues to see if you got a 200 DONE or something else. Also make sure you download the entire code in the link "here" which is a zip file with the entire project. You may also be timing out with no response which indicates your request was bad.
– jdweng
Nov 22 at 20:57
Did you use a sniffer like wireshark or fiddler to see what response you actually got. Check the response statues to see if you got a 200 DONE or something else. Also make sure you download the entire code in the link "here" which is a zip file with the entire project. You may also be timing out with no response which indicates your request was bad.
– jdweng
Nov 22 at 20:57
@jdweng yep! I did! i used fiddler and the response was 200 well done! but In a try catch, writes me in a logger "the auxiliary token signatures that are not expected" it seems that dot net is waiting for an unsigned response. My idea is to eliminate the signature in the response; so what I want is.. that, it does not write that kind of error!
– ger
Nov 22 at 21:09
@jdweng yep! I did! i used fiddler and the response was 200 well done! but In a try catch, writes me in a logger "the auxiliary token signatures that are not expected" it seems that dot net is waiting for an unsigned response. My idea is to eliminate the signature in the response; so what I want is.. that, it does not write that kind of error!
– ger
Nov 22 at 21:09
Once you get a 200 DONE there is no more data. If Net is waiting then maybe it is expecting http 1.1 (chunk mode) instead of 1.0 (stream mode). You are looking for security which is https but it looks like you are getting non secure http.
– jdweng
Nov 22 at 21:43
Once you get a 200 DONE there is no more data. If Net is waiting then maybe it is expecting http 1.1 (chunk mode) instead of 1.0 (stream mode). You are looking for security which is https but it looks like you are getting non secure http.
– jdweng
Nov 22 at 21:43
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435639%2ftrying-implement-a-custom-encoder-in-wcf%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435639%2ftrying-implement-a-custom-encoder-in-wcf%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you use a sniffer like wireshark or fiddler to see what response you actually got. Check the response statues to see if you got a 200 DONE or something else. Also make sure you download the entire code in the link "here" which is a zip file with the entire project. You may also be timing out with no response which indicates your request was bad.
– jdweng
Nov 22 at 20:57
@jdweng yep! I did! i used fiddler and the response was 200 well done! but In a try catch, writes me in a logger "the auxiliary token signatures that are not expected" it seems that dot net is waiting for an unsigned response. My idea is to eliminate the signature in the response; so what I want is.. that, it does not write that kind of error!
– ger
Nov 22 at 21:09
Once you get a 200 DONE there is no more data. If Net is waiting then maybe it is expecting http 1.1 (chunk mode) instead of 1.0 (stream mode). You are looking for security which is https but it looks like you are getting non secure http.
– jdweng
Nov 22 at 21:43