WCF Distributed development Common error (s): Start element ' Binary ' expected (expected initial element is ' Binary ')
WCF Distributed development Common error (s): Start element ' Binary ' expected (expected initial element is ' Binary '). Found ' SayHello '.
Debugging WCF4.0 code encountered errors, the current network reference to the information is very little, I put this information to collect the exception, including solutions, sorted for an article for your reference. There is no reference to this question at present. The use of Google also can not search the relevant English help materials. Share it, it should be a bit of reference value to everyone.
"1" Error description:
The problem is in debugging today I encountered this error while debugging WCF custom bindings to implement the bytestreammessageencoding code for the byte stream coding program. The exception that the client throws is: Start element ' Binary ' expected (the expected initial element is ' Binary '). Found ' SayHello '.
The binding is defined as follows:
//创建自定义绑定
ByteStreamMessageEncodingBindingElement byteStream = new ByteStreamMessageEncodingBindingElement();
//TcpTransportBindingElement transport = new TcpTransportBindingElement();
HttpTransportBindingElement transport = new HttpTransportBindingElement();
transport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
transport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
CustomBinding binding = new CustomBinding(byteStream, transport);
The operation is defined as follows:
2. Service class, inherit interface. Implementation of the service contract definition of the public
class Wcfservice:iwcfservice
{
//Implementation Interface definition method public
void SayHello (byte[] b)
{
Console.WriteLine ("Hello! {0},calling at {1}
... ", b,datetime.now.tolongtimestring ());
return b;
}
}
"2" Error screenshot:
Run the program, the client invokes the service operation, throws the exception screenshot as follows: