You can send complex types through leisure.
[ServiceContract] public interface ICustomerSpecialOrderService { [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "deletecso/")] bool DeleteCustomerOrder(CustomerSpecialOrder orderToDelete); }
The implementation is as follows:
public bool DeleteCustomerOrder(CustomerSpecialOrder orderToDelete) {
You can call the method from the WPF client:
public void DeleteMyOrder(CustomerSpecialOrder toDelete) { Uri address = new Uri(your_uri_here); var factory = new WebChannelFactory<ICustomerSpecialOrderService>(address); var webHttpBinding = factory.Endpoint.Binding as WebHttpBinding; ICustomerSpecialOrderService service = factory.CreateChannel(); service.DeleteCustomerOrder(toDelete); }
Or you can also call it using HttpWebRequest by writing a complex type to a byte array that we do from a mobile client.
private HttpWebRequest DoInvokeRequest<T>(string uri, string method, T requestBody) { string destinationUrl = _baseUrl + uri; var invokeRequest = WebRequest.Create(destinationUrl) as HttpWebRequest; if (invokeRequest == null) return null;
Brett bim
source share