使用邮递员测试 WCF 服务 [英] Test WCF Service using postman
问题描述
我开发了我的第一个 WCF 服务,我想使用邮递员进行测试,但我不断收到 404 not found 错误.我使用 WCFClient 对其进行了测试,并且运行良好.我的模型
[数据契约]公共类聊天机器人模型{[数据成员]公共 System.Guid id { 获取;放;}[数据成员]公共字符串主题 { 获取;放;}[数据成员]public Nullabledate_started { 获取;放;}}
我的功能:
public bool InsertChatBotData(chatbotModel 模型){使用 (var chatBotContext = new regacrmEntities()){var id = Guid.NewGuid();var NewchatBot = new a01_chatbot(){id = id,date_entered = model.date_started,date_modified = model.date_ended,名称 = 模型.主题,描述 = 模型.描述};chatBotContext.a01_chatbot.Add(NewchatBot);chatBotContext.SaveChanges();返回真;}}[服务合同]公共接口 ICrmService{【经营合同】[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Xml, UriTemplate = "InsertChatBotData")]bool InsertChatBotData(chatbotModel 模型);}
邮递员请求:我添加了标题:
SOAPAction:
帮助文档包括请求的 url、http 动词和请求的格式.
I developed my first WCF Service and I want to test using postman but I keep getting 404 not found error. I tested it using WCFClient and it was working fine. My Model
[DataContract]
public class chatbotModel
{
[DataMember]
public System.Guid id { get; set; }
[DataMember]
public string subject { get; set; }
[DataMember]
public Nullable<System.DateTime> date_started { get; set; }
}
My function:
public bool InsertChatBotData(chatbotModel model)
{
using (var chatBotContext = new regacrmEntities())
{
var id = Guid.NewGuid();
var NewchatBot = new a01_chatbot()
{
id = id,
date_entered = model.date_started,
date_modified = model.date_ended,
name = model.subject,
description = model.description
};
chatBotContext.a01_chatbot.Add(NewchatBot);
chatBotContext.SaveChanges();
return true;
}
}
[ServiceContract]
public interface ICrmService
{
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Xml, UriTemplate = "InsertChatBotData")]
bool InsertChatBotData(chatbotModel model);
}
Postman request: I added the header:
SOAPAction:http://tempuri.org/ICrmService/InsertChatBotData
This is because you visited the wrong URL, I suggest you enable the help document. Here is a demo:
<endpointBehaviors>
<behavior name="ESEndPointBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
You need to apply ESEndPointBehavior to the endpoint.
Then you can access the help document in your browser:
The help document includes the requested url, http verb and the requested format.
这篇关于使用邮递员测试 WCF 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!