Wcf Facility: wcf clients cannot be casted to IContextChannel

117 views
Skip to first unread message

ppcanodehuelva

unread,
Jan 3, 2009, 1:57:47 PM1/3/09
to Castle Project Users, cneu...@gmail.com
Hi,

i began to register some wcf proxy/client in the container.

Before, I was using the proxies and accessing the OperationContext in
such way:

ICrudTransferFactory p =
ChannelFactory<ICrudTransferFactory>.CreateChannel(new BasicHttpBinding
(), new EndpointAddress(_endpointAddress));
using (new OperationContextScope((IContextChannel)p))
{
OperationContext.Current.OutgoingMessageHeaders.Add
(MessageHeader.CreateHeader(CrudTransfer.HeaderIdName,
CrudTransfer.HeaderIdNamespaceUri, new CrudHeader(sid)));
Endpoint e = _proxy.Place(new CrudItem("ex1"));
}

-------------------------------------------------------------------------------------

When the container retrieves the proxy, such proxy cannot be casted to
IContextChannel (System.InvalidCastException comes out)

component 'crudfactory_proxy', ICrudTransferFactory:
ClientModel = DefaultClientModel( WcfEndpoint.BoundTo(_binding).At
(_crudFactoryEA) )


ICrudTransferFactory castleProxy =
_container.Resolve<ICrudTransferFactory>("crudfactory_proxy");
using (new OperationContextScope((IContextChannel)
castleProxy))
{
OperationContext.Current.OutgoingMessageHeaders.Add
(MessageHeader.CreateHeader(CrudTransfer.HeaderIdName,
CrudTransfer.HeaderIdNamespaceUri, new CrudHeader(sid)));
Endpoint e = castleProxy.Place(new CrudItem
("ex2"));
}

----------------------------------------------------------
Is there a way to get the IContextChannel from the client?
Shouldn't both ClientChannels work on the same way in order the client
must not be Castle-aware?


Many thanks in advance, regards.


Reply all
Reply to author
Forward
0 new messages