public void WcfServiceCall_DeserializesStringCorrectly() { //Arrange string testMessage = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<s:Header>" + "<Action s:mustUnderstand=\"1\" xmlns=\"http://schemas.microsoft.com/ws/2005/05/addressing/none\">http://tempuri.org/IService/DoSomething</Action>" + "</s:Header>" + "<s:Body>" + "<DoSomething xmlns=\"http://tempuri.org/\">" + "<aaa>SOMEVAL1</aaa>" + "<bbb>SOMEVAL2</bbb>" + "</DoSomething>" + "</s:Body>" + "</s:Envelope>"; //Act var result = new WcfServiceCall(testMessage); //Assert Assert.IsNotNull(result); Assert.AreEqual("DoSomething", result.ActionName); Assert.AreEqual("IService", result.ServiceName); Assert.AreEqual(2, result.Parameters.Count); Assert.AreEqual("aaa", result.Parameters[0].Name); Assert.AreEqual("SOMEVAL1", result.Parameters[0].value); Assert.AreEqual("bbb", result.Parameters[1].Name); Assert.AreEqual("SOMEVAL2", result.Parameters[1].value); Assert.AreEqual("IService:DoSomething(aaa,bbb)->(SOMEVAL1,SOMEVAL2)", result.ToString()); }
/// <summary> /// Enables inspection or modification of a message before a request message is sent to a service. /// </summary> /// <param name="request">The message to be sent to the service.</param> /// <param name="channel">The client object channel.</param> /// <returns> /// The object that is returned as the <paramref name="correlationState " />argument of the <see cref="M:System.ServiceModel.Dispatcher.IClientMessageInspector.AfterReceiveReply(System.ServiceModel.Channels.Message@,System.Object)" /> method. This is null if no correlation state is used.The best practice is to make this a <see cref="T:System.Guid" /> to ensure that no two <paramref name="correlationState" /> objects are the same. /// </returns> public object BeforeSendRequest(ref Message request, IClientChannel channel) { var m = new WcfServiceCall(request); string requestId = "Not set"; var s = HttpContext.Current.Items[Constants.HTTP_REQUEST_ID]; if (s != null) { requestId = s.ToString(); } LogEventInfo logEvent = new LogEventInfo(LogLevel.Debug, "BeforeSendRequest", m.ToString()); logEvent.Properties[Constants.WCF_SERVICE_NAME] = m.ServiceName; logEvent.Properties[Constants.WCF_ACTION_NAME] = m.ActionName; logEvent.Properties[Constants.HTTP_REQUEST_ID] = requestId; logger.Log(logEvent); return null; }