Test WCF Service using postman

5.4k Views Asked by At

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: enter image description here I added the header:

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

1

There are 1 best solutions below

0
On BEST ANSWER

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:

enter image description here

enter image description here

The help document includes the requested url, http verb and the requested format.