public static void ClientMessageInspector_Verify_Invoke() { // This test verifies ClientMessageInspector can be added to the client endpoint behaviors // and this is it called properly when a message is sent. StringBuilder errorBuilder = new StringBuilder(); try { CustomBinding customBinding = new CustomBinding(); customBinding.Elements.Add(new TextMessageEncodingBindingElement()); customBinding.Elements.Add(new HttpTransportBindingElement()); MyClientBase client = new MyClientBase(customBinding, new EndpointAddress(BaseAddress.HttpBaseAddress)); // Add the ClientMessageInspector and give it an instance where it can record what happens when it is called. ClientMessageInspectorData data = new ClientMessageInspectorData(); client.Endpoint.EndpointBehaviors.Add(new ClientMessageInspectorBehavior(data)); IWcfServiceGenerated serviceProxy = client.ChannelFactory.CreateChannel(); // This proxy call should invoke the client message inspector string result = serviceProxy.Echo("Hello"); if (!string.Equals(result, "Hello")) { errorBuilder.AppendLine(String.Format("Expected response from Service: {0} Actual was: {1}", "Hello", result)); } if (!data.BeforeSendRequestCalled) { errorBuilder.AppendLine(String.Format("Did not call BeforeSendRequest")); } if (data.Request == null) { errorBuilder.AppendLine(String.Format("Did not call pass Request to BeforeSendRequest")); } if (data.Channel == null) { errorBuilder.AppendLine(String.Format("Did not call pass Channel to BeforeSendRequest")); } if (!data.AfterReceiveReplyCalled) { errorBuilder.AppendLine(String.Format("Did not call AfterReceiveReplyCalled")); } if (data.Reply == null) { errorBuilder.AppendLine(String.Format("Did not call pass Reply to AfterReceiveReplyCalled")); } } catch (Exception ex) { errorBuilder.AppendLine(String.Format("Unexpected exception was caught: {0}", ex.ToString())); } Assert.True(errorBuilder.Length == 0, string.Format("Test Scenario: ClientMessageInspectorScenario FAILED with the following errors: {0}", errorBuilder)); }
public static void ClientMessageInspector_Verify_Invoke() { // This test verifies ClientMessageInspector can be added to the client endpoint behaviors // and this is it called properly when a message is sent. StringBuilder errorBuilder = new StringBuilder(); try { CustomBinding customBinding = new CustomBinding(); customBinding.Elements.Add(new TextMessageEncodingBindingElement()); customBinding.Elements.Add(new HttpTransportBindingElement()); MyClientBase client = new MyClientBase(customBinding, new EndpointAddress(BaseAddress.HttpBaseAddress)); // Add the ClientMessageInspector and give it an instance where it can record what happens when it is called. ClientMessageInspectorData data = new ClientMessageInspectorData(); client.Endpoint.EndpointBehaviors.Add(new ClientMessageInspectorBehavior(data)); IWcfServiceGenerated serviceProxy = client.ChannelFactory.CreateChannel(); // This proxy call should invoke the client message inspector string result = serviceProxy.Echo("Hello"); if (!string.Equals(result, "Hello")) { errorBuilder.AppendLine(String.Format("Expected response from Service: {0} Actual was: {1}", "Hello", result)); } if (!data.BeforeSendRequestCalled) { errorBuilder.AppendLine(String.Format("Did not call BeforeSendRequest")); } if (data.Request == null) { errorBuilder.AppendLine(String.Format("Did not call pass Request to BeforeSendRequest")); } if (data.Channel == null) { errorBuilder.AppendLine(String.Format("Did not call pass Channel to BeforeSendRequest")); } if (!data.AfterReceiveReplyCalled) { errorBuilder.AppendLine(String.Format("Did not call AfterReceiveReplyCalled")); } if (data.Reply == null) { errorBuilder.AppendLine(String.Format("Did not call pass Reply to AfterReceiveReplyCalled")); } } catch (Exception ex) { errorBuilder.AppendLine(String.Format("Unexpected exception was caught: {0}", ex.ToString())); } Assert.True(errorBuilder.Length == 0, string.Format("Test Scenario: ClientMessageInspectorScenario FAILED with the following errors: {0}", errorBuilder)); }
public static void ClientMessageInspector_Verify_Invoke() { // This test verifies ClientMessageInspector can be added to the client endpoint behaviors // and this is it called properly when a message is sent. MyClientBase client = null; IWcfServiceGenerated serviceProxy = null; try { // *** SETUP *** \\ CustomBinding customBinding = new CustomBinding(); customBinding.Elements.Add(new TextMessageEncodingBindingElement()); customBinding.Elements.Add(new HttpTransportBindingElement()); client = new MyClientBase(customBinding, new EndpointAddress(Endpoints.DefaultCustomHttp_Address)); // Add the ClientMessageInspector and give it an instance where it can record what happens when it is called. ClientMessageInspectorData data = new ClientMessageInspectorData(); client.Endpoint.EndpointBehaviors.Add(new ClientMessageInspectorBehavior(data)); serviceProxy = client.ChannelFactory.CreateChannel(); // *** EXECUTE *** \\ // This proxy call should invoke the client message inspector string result = serviceProxy.Echo("Hello"); // *** VALIDATE *** \\ Assert.Equal("Hello", result); Assert.True(data.BeforeSendRequestCalled, "BeforeSendRequest should have been called"); Assert.True(data.Request != null, "Did not call pass Request to BeforeSendRequest"); Assert.True(data.Channel != null, "Did not call pass Channel to BeforeSendRequest"); Assert.True(data.AfterReceiveReplyCalled, "AfterReceiveReplyCalled should have been called"); Assert.True(data.Reply != null, "Did not call pass Reply to AfterReceiveReplyCalled"); // *** CLEANUP *** \\ ((ICommunicationObject)client).Close(); ((ICommunicationObject)serviceProxy).Close(); } finally { // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, (ICommunicationObject)client); } }
public static void ClientMessageInspector_Verify_Invoke() { // This test verifies ClientMessageInspector can be added to the client endpoint behaviors // and this is it called properly when a message is sent. MyClientBase client = null; IWcfServiceGenerated serviceProxy = null; try { // *** SETUP *** \\ CustomBinding customBinding = new CustomBinding(); customBinding.Elements.Add(new TextMessageEncodingBindingElement()); customBinding.Elements.Add(new HttpTransportBindingElement()); client = new MyClientBase(customBinding, new EndpointAddress(Endpoints.DefaultCustomHttp_Address)); // Add the ClientMessageInspector and give it an instance where it can record what happens when it is called. ClientMessageInspectorData data = new ClientMessageInspectorData(); client.Endpoint.EndpointBehaviors.Add(new ClientMessageInspectorBehavior(data)); serviceProxy = client.ChannelFactory.CreateChannel(); // *** EXECUTE *** \\ // This proxy call should invoke the client message inspector string result = serviceProxy.Echo("Hello"); // *** VALIDATE *** \\ Assert.Equal("Hello", result); Assert.True(data.BeforeSendRequestCalled, "BeforeSendRequest should have been called"); Assert.True(data.Request != null, "Did not call pass Request to BeforeSendRequest"); Assert.True(data.Channel != null, "Did not call pass Channel to BeforeSendRequest"); Assert.True(data.AfterReceiveReplyCalled, "AfterReceiveReplyCalled should have been called"); Assert.True(data.Reply != null, "Did not call pass Reply to AfterReceiveReplyCalled"); // *** CLEANUP *** \\ ((ICommunicationObject)client).Close(); ((ICommunicationObject)serviceProxy).Close(); } finally { // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, (ICommunicationObject)client); } }
public ClientBaseMessageInspector(ClientMessageInspectorData data) { _data = data; }
public ClientMessageInspectorBehavior(ClientMessageInspectorData data) { _inspector = new ClientBaseMessageInspector(data); }
public ClientMessageInspector(ClientMessageInspectorData data) { _data = data; }
public ClientMessageInspectorBehavior(ClientMessageInspectorData data) { _inspector = new ClientMessageInspector(data); }