Tag: webhttpbinding

WCF执行错误:此工厂启用了手动寻址,因此必须预先发送所有发送的消息

我有一个使用WebHttpBinding托管的WCF服务。 服务非常简单,是一个接受多个参数的操作合同。 使用“添加服务引用”后自动生成的我的WCF客户端无法直接使用WCF服务。 该错误仅发生在WebHttpBinding而不是其他错误。 服务器端 [OperationContract] [WebInvoke(Method = “POST”, UriTemplate = “Submit2String”, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped)] string Submit2String(string input1, string input2); 客户端 ExpenseServiceClient proxy = new ExpenseServiceClient(); proxy.Submit2String(“test1”, “test2”); 当我测试运行上面的代码时,我收到以下错误: Error: InvalidOperationException was unhandled by user code Manual addressing is enabled on this factory, so all messages sent must be […]

带有BaseAddress的HttpClient

我在使用HttpClient和BaseAddress属性调用webHttpBinding WCF端点时遇到问题。 HttpClient的 我创建了一个HttpClient实例,将BaseAddress属性指定为本地主机端点。 GetAsync Call 然后我调用GetAsync方法传递额外的Uri信息。 HttpResponseMessage response = await client.GetAsync(string.Format(“/Layouts/{0}”, machineInformation.LocalMachineName())); 服务端点 [OperationContract] [WebGet(UriTemplate = “/Layouts/{machineAssetName}”, ResponseFormat = WebMessageFormat.Json)] List GetLayouts(string machineAssetName); 问题 我遇到的问题是,BaseAddress的/AndonService.svc部分被截断,因此结果调用转到https://localhost:44302/Layouts/1100-00277而不是https://localhost:44302/AndonService.svc/Layouts/1100-00277导致404 Not Found。 是否有理由在GetAsync调用中截断BaseAddress? 我该如何解决这个问题?