使用邮递员测试WCF服务

时间:2020-10-18 10:21:31

标签: wcf postman wcftestclient

我开发了我的第一个WCF服务,我想使用邮递员进行测试,但是我不断收到404 not found错误。 我使用WCFClient对其进行了测试,并且工作正常。 我的模特

  [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; }
    }

我的功能:

 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);

}

邮递员要求: enter image description here 我添加了标题:

SOAPAction:http://tempuri.org/ICrmService/InsertChatBotData

1 个答案:

答案 0 :(得分:0)

这是因为您访问了错误的URL,建议您启用帮助文档。这是一个演示:

        <endpointBehaviors>
            <behavior name="ESEndPointBehavior">
                <webHttp helpEnabled="true"/>
            </behavior>
        </endpointBehaviors>

您需要将 ESEndPointBehavior 应用于端点。

然后,您可以在浏览器中访问帮助文档:

enter image description here

enter image description here

帮助文档包括请求的URL,http动词和请求的格式。