Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ServiceContract]
- public interface IService
- {
- [OperationContract]
- string Invoke(string input);
- }
- public class Service : IService
- {
- public string Invoke(string input)
- {
- return input;
- }
- }
- public class OperationSelector : IDispatchOperationSelector
- {
- public string SelectOperation(ref Message message)
- {
- return "Invoke";
- }
- }
- public class EndpointBehavior : IEndpointBehavior
- {
- public void Validate(ServiceEndpoint endpoint)
- { }
- public void AddBindingParameters(ServiceEndpoint endpoint,
- BindingParameterCollection bindingParameters)
- { }
- public void ApplyDispatchBehavior(ServiceEndpoint endpoint,
- EndpointDispatcher endpointDispatcher)
- {
- endpointDispatcher.DispatchRuntime.OperationSelector = new OperationSelector();
- }
- public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
- { }
- }
- static void Main(string[] args)
- {
- var host = new ServiceHost(typeof(Service),
- new Uri("http://localhost:8000/Service.svc"));
- var endpoint = host.AddServiceEndpoint(typeof(IService), new BasicHttpBinding(), "");
- endpoint.Behaviors.Add(new EndpointBehavior());
- host.Open();
- Console.ReadLine();
- host.Close();
- }
- POST http://localhost:8000/Service.svc HTTP/1.1
- Content-Type: text/xml; charset=utf-8
- SOAPAction: "http://tempuri.org/IService/Invoke"
- Host: localhost:8000
- Expect: 100-continue
- Accept-Encoding: gzip, deflate
- Connection: Keep-Alive
- Content-Length: 158
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><Invoke xmlns="http://tempuri.org/"><input>Test</input></Invoke></s:Body></s:Envelope>
- [OperationContract(Action = "*")]
- void UnrecognizedMessageHandler(Message msg);
Advertisement
Add Comment
Please, Sign In to add comment