public string LastPosition(string messageXml) { LastPositionResponseTypeMessage responseMsg; LastPositionRequestTypeMessage request = null; try { $"<LastPositionRequestType>{messageXml}</LastPositionRequestType>".XDocValidate(Utils.GetSchemas()); request = messageXml.DeserializeFromXmlString <LastPositionRequestTypeMessage>(); Logger.LogInformation(AvlLogEvent.LastPositionCall, request.Header.SessionID, null); responseMsg = BL.LastPosition(request); } catch (XmlSchemaValidationException ex) { Logger.LogError(ex, request != null ? request.Header.SessionID : 0, "LastPosition request validation error."); responseMsg = new LastPositionResponseTypeMessage() { Header = new Header() { MessageIDSpecified = true, SessionIDSpecified = true, MessageID = -1, SessionID = -1 }, Body = new LastPositionResponseTypeMessageBody() { LastPositionResponse = new LastPositionResponseTypeMessageBodyLastPositionResponse() { Status = false, Description = "XML syntax error in request", VehicleList = new LastPositionResponseTypeMessageBodyLastPositionResponseVehicle[] { } } } }; } string responseStr = responseMsg.SerializeToXmlString(); $"<LastPositionResponseType>{responseStr}</LastPositionResponseType>".XDocValidate(Utils.GetSchemas()); Logger.LogDebug(AvlLogEvent.LastPositionCall, responseMsg.Header.SessionID, "Response sent: {responseStr}", responseStr); return(responseStr); }