B
Ben
Hi all,
I'm reading the book Essential WCF and while trying out the code listing at
page 95 I got an ArgumentException when running the code.
Here's the code listing:
BasicHttpBinding binding = new BasicHttpBinding();
BindingParameterCollection parameters = new
BindingParameterCollection();
Message m = Message.CreateMessage(MessageVersion.Soap11,
"urn:sendmessage");
IChannelFactory<IOutputChannel> factory =
binding.BuildChannelFactory<IOutputChannel>(parameters);
IOutputChannel channel = factory.CreateChannel(new
EndpointAddress("http://localhost/sendmessage/"));
channel.Send(m);
channel.Close();
factory.Close();
I tried to use some other channel types what nothing helped. I got an
exception all the time.
Then I looked at the stack trace and noticed that the exception is thrown
from the method TransactionFlowBindingElement.BuildChannelFactory. I fired up
Reflector and saw that this method internally calls the method
CanBuildChannelFactory of the same class. Inside this method there is this
check:
if ((((typeof(TChannel) != typeof(IOutputChannel)) && (typeof(TChannel) !=
typeof(IDuplexChannel))) && ((typeof(TChannel) != typeof(IRequestChannel)) &&
(typeof(TChannel) != typeof(IOutputSessionChannel)))) && ((typeof(TChannel)
!= typeof(IRequestSessionChannel)) && (typeof(TChannel) !=
typeof(IDuplexSessionChannel))))
{
return false;
}
Does this seem like a valid check? Shouldn't it be using || instead of all
the &&?
Perhaps I'm getting all this wrong and can't figure the code listing from
the book right.
Thanks,
Ben
I'm reading the book Essential WCF and while trying out the code listing at
page 95 I got an ArgumentException when running the code.
Here's the code listing:
BasicHttpBinding binding = new BasicHttpBinding();
BindingParameterCollection parameters = new
BindingParameterCollection();
Message m = Message.CreateMessage(MessageVersion.Soap11,
"urn:sendmessage");
IChannelFactory<IOutputChannel> factory =
binding.BuildChannelFactory<IOutputChannel>(parameters);
IOutputChannel channel = factory.CreateChannel(new
EndpointAddress("http://localhost/sendmessage/"));
channel.Send(m);
channel.Close();
factory.Close();
I tried to use some other channel types what nothing helped. I got an
exception all the time.
Then I looked at the stack trace and noticed that the exception is thrown
from the method TransactionFlowBindingElement.BuildChannelFactory. I fired up
Reflector and saw that this method internally calls the method
CanBuildChannelFactory of the same class. Inside this method there is this
check:
if ((((typeof(TChannel) != typeof(IOutputChannel)) && (typeof(TChannel) !=
typeof(IDuplexChannel))) && ((typeof(TChannel) != typeof(IRequestChannel)) &&
(typeof(TChannel) != typeof(IOutputSessionChannel)))) && ((typeof(TChannel)
!= typeof(IRequestSessionChannel)) && (typeof(TChannel) !=
typeof(IDuplexSessionChannel))))
{
return false;
}
Does this seem like a valid check? Shouldn't it be using || instead of all
the &&?
Perhaps I'm getting all this wrong and can't figure the code listing from
the book right.
Thanks,
Ben