такой код с Json запросом
[ServiceContract] public interface IService { [OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "/test/?test2={test2}") ] Test Testing(Test test2); } public class Service : IService { public Test Testing(Test test2) { Test testI = test2; return new Test() { str="all done" }; } } public class Test { public string str { get; set; } } class Program { static void Main(string[] args) { ServiceHost host = new ServiceHost(typeof(Service), new Uri("http://localhost:8000")); host.AddServiceEndpoint(typeof(IService), new BasicHttpBinding(), "Soap"); ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(IService), new WebHttpBinding(), "Web"); endpoint.Behaviors.Add(new WebHttpBehavior()); try { host.Open(); Console.WriteLine("Press [Enter] to terminate"); Console.ReadLine(); host.Close(); } catch (CommunicationException cex) { Console.WriteLine("An exception occurred: {0}", cex.Message); host.Abort(); } } }
могу я отправить через интерфейс test2 с типом Test в “http://localhost:8000/web/test/?test2={test2}”?