public static void SameBinding_Binary_EchoComplexString() { string variationDetails = "Client:: CustomBinding/BinaryEncoder/Http\nServer:: CustomBinding/BinaryEncoder/Http"; StringBuilder errorBuilder = new StringBuilder(); bool success = false; try { CustomBinding binding = new CustomBinding(new BinaryMessageEncodingBindingElement(), new HttpTransportBindingElement()); ChannelFactory <IWcfService> factory = new ChannelFactory <IWcfService>(binding, new EndpointAddress(Endpoints.HttpBinary_Address)); IWcfService serviceProxy = factory.CreateChannel(); ComplexCompositeType compositeObject = ScenarioTestHelpers.GetInitializedComplexCompositeType(); ComplexCompositeType result = serviceProxy.EchoComplex(compositeObject); success = compositeObject.Equals(result); if (!success) { errorBuilder.AppendLine(String.Format(" Error: expected response from service: '{0}' Actual was: '{1}'", compositeObject, result)); } } catch (Exception ex) { errorBuilder.AppendLine(String.Format(" Error: Unexpected exception was caught while doing the basic echo test for variation...\n'{0}'\nException: {1}", variationDetails, ex.ToString())); for (Exception innerException = ex.InnerException; innerException != null; innerException = innerException.InnerException) { errorBuilder.AppendLine(String.Format("Inner exception: {0}", innerException.ToString())); } } Assert.True(errorBuilder.Length == 0, errorBuilder.ToString()); }
public static void SameBinding_Binary_EchoComplexString() { CustomBinding binding = null; ChannelFactory <IWcfService> factory = null; EndpointAddress endpointAddress = null; IWcfService serviceProxy = null; ComplexCompositeType compositeObject = null; ComplexCompositeType result = null; try { // *** SETUP *** \\ binding = new CustomBinding(new BinaryMessageEncodingBindingElement(), new HttpTransportBindingElement()); endpointAddress = new EndpointAddress(Endpoints.HttpBinary_Address); factory = new ChannelFactory <IWcfService>(binding, endpointAddress); serviceProxy = factory.CreateChannel(); compositeObject = ScenarioTestHelpers.GetInitializedComplexCompositeType(); // *** EXECUTE *** \\ result = serviceProxy.EchoComplex(compositeObject); // *** VALIDATE *** \\ Assert.True(compositeObject.Equals(result), String.Format(" Error: expected response from service: '{0}' Actual was: '{1}'", compositeObject, result)); // *** CLEANUP *** \\ factory.Close(); ((ICommunicationObject)serviceProxy).Close(); } finally { // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory); } }