c# - 如何修复错误 Endpoint not found WCF REST POST
问题描述
我有一个以字符串为输入的 WCF REST 服务,
IService.cs:
[ServiceContract]
public interface IServiceImportAutoLiasse
{
[OperationContract]
[WebInvoke(Method = "POST",BodyStyle = WebMessageBodyStyle.Bare)]
string PostJson(string request);
}
IService.svc.cs:
public string PostJson(string request)
{
//...
}
我验证了 web.config ,它做得很好:
<services>
<!--SOAP-->
<service behaviorConfiguration="ServBehavior" name="SysLap.Services.Web.ImportAutoLiasse.Service">
<endpoint address="soap" binding="basicHttpBinding" bindingConfiguration="BindingCongHttp"
contract="SysLap.Services.Web.ImportAutoLiasse.IService" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<!--REST-->
<endpoint address="rest" behaviorConfiguration="webHttpBhavior" bindingConfiguration="BindingConfigWebHttp"
binding="webHttpBinding" contract="SysLap.Services.Web.ImportAutoLiasse.IService" />
</service>
</services>
我用 POSTMAN 测试它:
https://localhost:44355/ServiceImportAutoLiasse.svc/rest/PostJson
使用 JSON 输入:
{
"Headers": ["Header":"CA","Header":"Pe","Header":"RU","Header":"P_AMOUNT"],
"Values": ["value":"A;2019.12;S200;100","value":"A;2019.12;S000;1" ]
}
我有错误:
The server encountered an error processing the request. The exception message is 'There was an error
deserializing the object of type System.String. End element 'root' from namespace '' expected. Found element
'Headers' from namespace ''.'. See server logs for more details
我收到错误:“找不到端点。”
我该如何解决?提前致谢,
解决方案
推荐阅读
- estimote - 将信息动态推送到 Estimote Beacon?
- python - 将 MP3 转换为 WAV
- docker - Ansible:将文件复制到 Docker 卷
- matlab - Matlab - 帮助使用名称模式列出文件
- css - Angular - 在路线更改时为外部元素设置动画
- python - Tkinter:如何访问要配置的标签?
- android - 弃用 Mapbox 的 setOnMapClickListener 方法
- database-design - 用于将数量部分地从一个位置移动到另一个位置的数据库模型
- kotlin - 如何抑制特定类的 Dokka 文档?
- xml - Powershell 将一批 xml 转换为 csv