I am having trouble connecting a WCF service to a ASMX service. I’ve created a custom binding in the WCF service:
The error I get is:
The header ‘Compression’ from the namespace ‘http://weblogs.shockbyte.com.ar/rodolfof/compression/2006/02’ was not understood by the recipient of this message, causing the message to not be processed. This error typically indicates that the sender of this message has enabled a communication …
Which lead me to this site. Any ideas on how I can correct my binding to communicate with the ASMX service?
The developer of the original ASMX service has long since left the company.
Your help would be greatly appreciated.
I followed your example and getting the Error as below
OperationFormatter encountered an invalid Message body. Expected to find node type ‘Element’ with name ‘GetLocaleStringResourceResponse’ and namespace ‘http://tempuri.org/’. Found node type ‘Element’ with name ‘sc:CompressedData’ and namespace ‘http://weblogs.shockbyte.com.ar/rodolfof/compression/2006/02’
var compressionHeader = new MessageHeader(compressionContent, true, “”, false);
newMsg.Headers.Add(compressionHeader.GetUntypedHeader(WcfCompressionValue.ElementNames.Compression, WcfCompressionValue.NamespaceURI));
//
namespace Test.EntityObjectWrapper
{
public class LocalizationEntityWrapper
{
public EntityWrapper Items { set; get; }
public LocalizationEntityWrapper()
{
Items = new EntityWrapper { new List(), new List() };
}
public List LocaleStringResourceItem()
{
if (Items == null)
return null;
return (List)Items[0];
}
public List LanguageEntityItem()
{
if (Items == null)
return null;
return (List)Items[1];
}
}
}
Loading...
I’m trying and I can not reproduce the error. You could send me by mail a test project which the complete code (your client code included) that is falling? Thks!
Rodolfo,
I am having trouble connecting a WCF service to a ASMX service. I’ve created a custom binding in the WCF service:
The error I get is:
The header ‘Compression’ from the namespace ‘http://weblogs.shockbyte.com.ar/rodolfof/compression/2006/02’ was not understood by the recipient of this message, causing the message to not be processed. This error typically indicates that the sender of this message has enabled a communication …
Which lead me to this site. Any ideas on how I can correct my binding to communicate with the ASMX service?
The developer of the original ASMX service has long since left the company.
Your help would be greatly appreciated.
Thanks.
Hi Jhon,
To enable WS-Compresión you need to configue the filter in both sides: the client and the server. You can see a example in the code published here: http://shockbyte.net/2006/04/06/new-version-of…ession-for-wcf/
Unfortunately the WS-Compression bindings is not compatible with ASM programming model.
Hi Rodolfo,
I followed your example and getting the Error as below
OperationFormatter encountered an invalid Message body. Expected to find node type ‘Element’ with name ‘GetLocaleStringResourceResponse’ and namespace ‘http://tempuri.org/’. Found node type ‘Element’ with name ‘sc:CompressedData’ and namespace ‘http://weblogs.shockbyte.com.ar/rodolfof/compression/2006/02’
Could you advise this?
Thanks
Hi,
You can send me the code that is failing?
Regards//
Hi Rodolfo,
Here you go.
//WcfCompressionInterceptor
public void OnSend(ref Message message)
{
Message newMsg = Compress(message);
MessageBuffer buffer = newMsg.CreateBufferedCopy(int.MaxValue);
// Close the original message
message.Close();
newMsg.Close();
message = buffer.CreateMessage();
buffer.Close();
}
//
public Message Compress(Message message)
{
var compressionContent = new WcfCompressionHeaderContent(Level);
string compressedBodyUri = WcfCompressionReferenceList.GenerateNewReference();
compressionContent.ReferenceList.AddReference(compressedBodyUri);
var document = new XmlDocument();
document.Load(message.GetReaderAtBodyContents());
XmlNode body = document.FirstChild;
var compressedData = new WcfCompressionCompressedData(compressionContent.Level, encryptionKey, compressedBodyUri);
MemoryStream compressedStream = compressedData.GetCompressedStream(body);
// Create new message
var xmlReader = new XmlTextReader(compressedStream);
Message newMsg = Message.CreateMessage(message.Version, null, xmlReader);
// Preserve the headers of the original message
newMsg.Headers.CopyHeadersFrom(message);
newMsg.Properties.CopyProperties(message.Properties);
var compressionHeader = new MessageHeader(compressionContent, true, “”, false);
newMsg.Headers.Add(compressionHeader.GetUntypedHeader(WcfCompressionValue.ElementNames.Compression, WcfCompressionValue.NamespaceURI));
return newMsg;
}
//Contracts
namespace Test.LocalizationFacade.Contracts
{
[ServiceContract, ServiceKnownType(typeof(List)), ServiceKnownType(typeof(List))]
public interface ILocalizationBF
{
[FaultContract(typeof(WcfFaultContract)), OperationContract]
LocalizationEntityWrapper GetLocaleStringResource(ParamLocaleStringResourceEntity paramEntity);
}
}
//
namespace Test.EntityObjectWrapper
{
public class LocalizationEntityWrapper
{
public EntityWrapper Items { set; get; }
public LocalizationEntityWrapper()
{
Items = new EntityWrapper { new List(), new List() };
}
public List LocaleStringResourceItem()
{
if (Items == null)
return null;
return (List)Items[0];
}
public List LanguageEntityItem()
{
if (Items == null)
return null;
return (List)Items[1];
}
}
}
I’m trying and I can not reproduce the error. You could send me by mail a test project which the complete code (your client code included) that is falling? Thks!
Hi rodolfo,
Can you PM me your email address?
Thanks