According to your description, I did a test but did not find the problem, here is my demo:
[ServiceContract]
public interface IService1
{
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "warehouse_shipping_advice")]
void WarehouseShippingAdvice(_WarehouseShipping newWarehouseShipping);
}
[DataContract]
public class _WarehouseShipping
{
[DataMember]
public string string001Value { get; set; }
}
public class Service1 : IService1
{
public void WarehouseShippingAdvice(_WarehouseShipping newWarehouseShipping)
{
Console.WriteLine(newWarehouseShipping.string001Value);
}
}
class Program
{
static void Main(string[] args)
{
// Step 1: Create a URI to serve as the base address.
Uri baseAddress = new Uri("http://localhost:8000/GettingStarted/");
// Step 2: Create a ServiceHost instance.
ServiceHost selfHost = new ServiceHost(typeof(Service1), baseAddress);
try
{
// Step 3: Add a service endpoint.
selfHost.AddServiceEndpoint(typeof(IService1), new WebHttpBinding(), "CalculatorService").Behaviors.Add(new WebHttpBehavior() { HelpEnabled=true});
// Step 4: Enable metadata exchange.
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
selfHost.Description.Behaviors.Add(smb);
// Step 5: Start the service.
selfHost.Open();
Console.WriteLine("The service is ready.");
// Close the ServiceHost to stop the service.
Console.WriteLine("Press <Enter> to terminate the service.");
Console.WriteLine();
Console.ReadLine();
selfHost.Close();
}
catch (CommunicationException ce)
{
Console.WriteLine("An exception occurred: {0}", ce.Message);
selfHost.Abort();
}
}
}
This is my service. I enabled the help document in the service.
According to the help document, we can request the service correctly.
UPDATE
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…