【发布时间】:2020-04-10 20:10:55
【问题描述】:
我有一个以字符串为输入的 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
我收到错误:“找不到端点。”
我该如何解决? 提前致谢,
【问题讨论】: