string add = String.Format("http://localhost:{0}/ServiceRequestRest",accessPort);
var cf = new ChannelFactory<IServiceRequestRest>(new WebHttpBinding(), add);
cf.Endpoint.Behaviors.Add(new WebHttpBehavior());
busService = cf.CreateChannel();
busService.DoMyStuff("hello",null);
当我激活“FirstChanceExceptionBreak”时,最后一行代码抛出一系列异常。第一个例外是:
System.InvalidOperationException occurred
Message="Envelope Version 'EnvelopeNone (http://schemas.microsoft.com/ws/2005/05/envelope/none)' does not support adding Message Headers."
Source="System.ServiceModel"
StackTrace:
at System.ServiceModel.Channels.MessageHeaders.ValidateHeaderKind(HeaderKind headerKind)
我不知道我正在尝试“添加邮件头”,但我选择继续执行并立即获取下一个异常:
System.Net.WebException occurred
Message="The underlying connection was closed: The connection was closed unexpectedly."
Source="System"
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
更新
:无法序列化REST调用的返回类型,我从
another site
更新2
interference from Skype
. 代码正在工作。:)