Add async_method_call to utility

Adding async_method_call in dbus utility gives us a place where we can
intercept method call requests from dbus to potentially add
logging/caching.

An example of logging is in the later commit:
https://gerrit.openbmc.org/c/openbmc/bmcweb/+/78265/

We already do this for setProperty, this moves the method calls to
follow a similar pattern.

Tested: Redfish service validator passes.

Change-Id: I6d2c96e2b6b6a023ed2138106a55faebca161592
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/redfish-core/include/snmp_trap_event_clients.hpp b/redfish-core/include/snmp_trap_event_clients.hpp
index 4a799b7..8f47664 100644
--- a/redfish-core/include/snmp_trap_event_clients.hpp
+++ b/redfish-core/include/snmp_trap_event_clients.hpp
@@ -3,7 +3,6 @@
 #pragma once
 
 #include "async_resp.hpp"
-#include "dbus_singleton.hpp"
 #include "dbus_utility.hpp"
 #include "error_messages.hpp"
 #include "event_service_manager.hpp"
@@ -91,7 +90,8 @@
 inline void getSnmpTrapClient(
     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& id)
 {
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, id](const boost::system::error_code& ec,
                         dbus::utility::ManagedObjectType& resp) {
             if (ec)
@@ -179,7 +179,8 @@
     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
     const std::string& host, uint16_t snmpTrapPort)
 {
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp,
          host](const boost::system::error_code& ec,
                const sdbusplus::message_t& msg, const std::string& dbusSNMPid) {
@@ -221,7 +222,8 @@
             "/xyz/openbmc_project/network/snmp/manager") /
         std::string(snmpTrapId);
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, param](const boost::system::error_code& ec) {
             if (ec)
             {
diff --git a/redfish-core/include/utils/chassis_utils.hpp b/redfish-core/include/utils/chassis_utils.hpp
index d9fcf59..bc856a6 100644
--- a/redfish-core/include/utils/chassis_utils.hpp
+++ b/redfish-core/include/utils/chassis_utils.hpp
@@ -3,6 +3,7 @@
 #pragma once
 
 #include "async_resp.hpp"
+#include "boost_formatters.hpp"
 #include "dbus_utility.hpp"
 #include "error_messages.hpp"
 #include "logging.hpp"
diff --git a/redfish-core/include/utils/sw_utils.hpp b/redfish-core/include/utils/sw_utils.hpp
index a803b51..f4872b5 100644
--- a/redfish-core/include/utils/sw_utils.hpp
+++ b/redfish-core/include/utils/sw_utils.hpp
@@ -4,6 +4,7 @@
 #include "bmcweb_config.h"
 
 #include "async_resp.hpp"
+#include "boost_formatters.hpp"
 #include "dbus_singleton.hpp"
 #include "dbus_utility.hpp"
 #include "error_messages.hpp"
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index d7f686c..63c51a8 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -9,7 +9,6 @@
 #include "async_resp.hpp"
 #include "boost_formatters.hpp"
 #include "certificate_service.hpp"
-#include "dbus_singleton.hpp"
 #include "dbus_utility.hpp"
 #include "error_messages.hpp"
 #include "generated/enums/account_service.hpp"
@@ -392,7 +391,8 @@
             // delete the existing object
             if (index < roleMapObjData.size())
             {
-                crow::connections::systemBus->async_method_call(
+                dbus::utility::async_method_call(
+                    asyncResp,
                     [asyncResp, roleMapObjData, serverType,
                      index](const boost::system::error_code& ec) {
                         if (ec)
@@ -506,7 +506,8 @@
                 BMCWEB_LOG_DEBUG("Remote Group={},LocalRole={}", *remoteGroup,
                                  *localRole);
 
-                crow::connections::systemBus->async_method_call(
+                dbus::utility::async_method_call(
+                    asyncResp,
                     [asyncResp, serverType, localRole,
                      remoteGroup](const boost::system::error_code& ec) {
                         if (ec)
@@ -1820,7 +1821,8 @@
         tempObjPath /= username;
         const std::string userPath(tempObjPath);
 
-        crow::connections::systemBus->async_method_call(
+        dbus::utility::async_method_call(
+            asyncResp,
             [asyncResp, password](const boost::system::error_code& ec3) {
                 if (ec3)
                 {
@@ -1912,7 +1914,8 @@
         messages::internalError(asyncResp->res);
         return;
     }
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, username, password](const boost::system::error_code& ec2,
                                         sdbusplus::message_t& m) {
             processAfterCreateUser(asyncResp, username, password, ec2, m);
@@ -2191,7 +2194,8 @@
     tempObjPath /= username;
     const std::string userPath(tempObjPath);
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, username](const boost::system::error_code& ec) {
             if (ec)
             {
@@ -2285,7 +2289,8 @@
                              locked, accountTypes, userSelf, req.session);
         return;
     }
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, username, password(std::move(password)),
          roleId(std::move(roleId)), enabled, newUser{std::string(*newUserName)},
          locked, userSelf, session = req.session,
diff --git a/redfish-core/lib/bios.hpp b/redfish-core/lib/bios.hpp
index 99635b2..560fe7f 100644
--- a/redfish-core/lib/bios.hpp
+++ b/redfish-core/lib/bios.hpp
@@ -6,7 +6,7 @@
 
 #include "app.hpp"
 #include "async_resp.hpp"
-#include "dbus_singleton.hpp"
+#include "dbus_utility.hpp"
 #include "error_messages.hpp"
 #include "http_request.hpp"
 #include "logging.hpp"
@@ -103,7 +103,8 @@
         return;
     }
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp](const boost::system::error_code& ec) {
             if (ec)
             {
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 645c242..6d69bc9 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -423,7 +423,8 @@
     const std::string& service,
     const sdbusplus::message::object_path& objectPath)
 {
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp,
          id{objectPath.filename()}](const boost::system::error_code& ec) {
             if (ec)
@@ -610,7 +611,8 @@
 
     std::shared_ptr<CertificateFile> certFile =
         std::make_shared<CertificateFile>(certificate);
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, certFile, objectPath, service, url{*parsedUrl}, id, name,
          certificate](const boost::system::error_code& ec,
                       sdbusplus::message_t& m) {
@@ -656,7 +658,8 @@
 {
     BMCWEB_LOG_DEBUG("getCSR CertObjectPath{} CSRObjectPath={} service={}",
                      certObjPath, csrObjPath, service);
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp,
          certURI](const boost::system::error_code& ec, const std::string& csr) {
             if (ec)
@@ -900,7 +903,8 @@
                 }
             }
         });
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp](const boost::system::error_code& ec, const std::string&) {
             if (ec)
             {
@@ -1007,7 +1011,8 @@
     std::shared_ptr<CertificateFile> certFile =
         std::make_shared<CertificateFile>(certHttpBody);
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, certFile](const boost::system::error_code& ec,
                               const std::string& objectPath) {
             if (ec)
@@ -1122,7 +1127,8 @@
     std::shared_ptr<CertificateFile> certFile =
         std::make_shared<CertificateFile>(certHttpBody);
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, certFile](const boost::system::error_code& ec,
                               const std::string& objectPath) {
             if (ec)
@@ -1260,7 +1266,8 @@
 
     std::shared_ptr<CertificateFile> certFile =
         std::make_shared<CertificateFile>(certHttpBody);
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, certFile](const boost::system::error_code& ec,
                               const std::string& objectPath) {
             if (ec)
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 879ae38..27a7dbc 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -153,7 +153,6 @@
  */
 inline void getChassisState(std::shared_ptr<bmcweb::AsyncResp> asyncResp)
 {
-    // crow::connections::systemBus->async_method_call(
     dbus::utility::getProperty<std::string>(
         "xyz.openbmc_project.State.Chassis",
         "/xyz/openbmc_project/state/chassis0",
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 1e547e4..1031e3d 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -7,7 +7,6 @@
 
 #include "app.hpp"
 #include "async_resp.hpp"
-#include "dbus_singleton.hpp"
 #include "dbus_utility.hpp"
 #include "error_messages.hpp"
 #include "generated/enums/ethernet_interface.hpp"
@@ -756,7 +755,8 @@
                             const std::string& ipHash,
                             const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
 {
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp](const boost::system::error_code& ec) {
             if (ec)
             {
@@ -792,8 +792,8 @@
             }
         };
 
-    crow::connections::systemBus->async_method_call(
-        std::move(createIpHandler), "xyz.openbmc_project.Network",
+    dbus::utility::async_method_call(
+        asyncResp, std::move(createIpHandler), "xyz.openbmc_project.Network",
         "/xyz/openbmc_project/network/" + ifaceId,
         "xyz.openbmc_project.Network.IP.Create", "IP",
         "xyz.openbmc_project.Network.IP.Protocol.IPv4", address, prefixLength,
@@ -820,7 +820,8 @@
     const std::string& gateway,
     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
 {
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, version, ifaceId, address, prefixLength,
          gateway](const boost::system::error_code& ec) {
             if (ec)
@@ -829,7 +830,8 @@
             }
             std::string protocol = "xyz.openbmc_project.Network.IP.Protocol.";
             protocol += version == IpVersion::IpV4 ? "IPv4" : "IPv6";
-            crow::connections::systemBus->async_method_call(
+            dbus::utility::async_method_call(
+                asyncResp,
                 [asyncResp](const boost::system::error_code& ec2) {
                     if (ec2)
                     {
@@ -918,9 +920,9 @@
         };
     // Passing null for gateway, as per redfish spec IPv6StaticAddresses
     // object does not have associated gateway property
-    crow::connections::systemBus->async_method_call(
-        std::move(createIpHandler), "xyz.openbmc_project.Network", path,
-        "xyz.openbmc_project.Network.IP.Create", "IP",
+    dbus::utility::async_method_call(
+        asyncResp, std::move(createIpHandler), "xyz.openbmc_project.Network",
+        path, "xyz.openbmc_project.Network.IP.Create", "IP",
         "xyz.openbmc_project.Network.IP.Protocol.IPv6", address, prefixLength,
         "");
 }
@@ -941,7 +943,8 @@
     sdbusplus::message::object_path path("/xyz/openbmc_project/network");
     path /= ifaceId;
     path /= gatewayId;
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp](const boost::system::error_code& ec) {
             if (ec)
             {
@@ -973,10 +976,11 @@
             messages::internalError(asyncResp->res);
         }
     };
-    crow::connections::systemBus->async_method_call(
-        std::move(createIpHandler), "xyz.openbmc_project.Network", path,
-        "xyz.openbmc_project.Network.StaticGateway.Create", "StaticGateway",
-        gateway, "xyz.openbmc_project.Network.IP.Protocol.IPv6");
+    dbus::utility::async_method_call(
+        asyncResp, std::move(createIpHandler), "xyz.openbmc_project.Network",
+        path, "xyz.openbmc_project.Network.StaticGateway.Create",
+        "StaticGateway", gateway,
+        "xyz.openbmc_project.Network.IP.Protocol.IPv6");
 }
 
 /**
@@ -998,7 +1002,8 @@
     sdbusplus::message::object_path path("/xyz/openbmc_project/network");
     path /= ifaceId;
     path /= gatewayId;
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, ifaceId, gateway](const boost::system::error_code& ec) {
             if (ec)
             {
@@ -2248,7 +2253,8 @@
 
                 std::string vlanInterface =
                     parentInterface + "_" + std::to_string(vlanId);
-                crow::connections::systemBus->async_method_call(
+                dbus::utility::async_method_call(
+                    asyncResp,
                     [asyncResp, parentInterfaceUri,
                      vlanInterface](const boost::system::error_code& ec,
                                     const sdbusplus::message_t& m) {
@@ -2501,7 +2507,8 @@
                     return;
                 }
 
-                crow::connections::systemBus->async_method_call(
+                dbus::utility::async_method_call(
+                    asyncResp,
                     [asyncResp, ifaceId](const boost::system::error_code& ec,
                                          const sdbusplus::message_t& m) {
                         afterDelete(asyncResp, ifaceId, ec, m);
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index fa003e3..66f49ab 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -4,7 +4,6 @@
 #pragma once
 #include "app.hpp"
 #include "async_resp.hpp"
-#include "dbus_singleton.hpp"
 #include "dbus_utility.hpp"
 #include "error_messages.hpp"
 #include "event_service_manager.hpp"
@@ -298,7 +297,8 @@
                         "/redfish/v1/EventService/Subscriptions/{}" + id);
                     memberArray.emplace_back(std::move(member));
                 }
-                crow::connections::systemBus->async_method_call(
+                dbus::utility::async_method_call(
+                    asyncResp,
                     [asyncResp](const boost::system::error_code& ec,
                                 const dbus::utility::ManagedObjectType& resp) {
                         doSubscriptionCollection(ec, asyncResp, resp);
diff --git a/redfish-core/lib/fan.hpp b/redfish-core/lib/fan.hpp
index 06dc187..baa25b3 100644
--- a/redfish-core/lib/fan.hpp
+++ b/redfish-core/lib/fan.hpp
@@ -12,6 +12,7 @@
 #include "query.hpp"
 #include "registries/privilege_registry.hpp"
 #include "utils/chassis_utils.hpp"
+#include "utils/dbus_utils.hpp"
 
 #include <asm-generic/errno.h>
 
diff --git a/redfish-core/lib/led.hpp b/redfish-core/lib/led.hpp
index e868bf3..b74dc4d 100644
--- a/redfish-core/lib/led.hpp
+++ b/redfish-core/lib/led.hpp
@@ -20,6 +20,7 @@
 #include <array>
 #include <functional>
 #include <memory>
+#include <string>
 #include <string_view>
 #include <utility>
 
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index cde992b..8d29341 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -590,8 +590,8 @@
         }
     };
 
-    crow::connections::systemBus->async_method_call(
-        respHandler, "xyz.openbmc_project.Dump.Manager",
+    dbus::utility::async_method_call(
+        asyncResp, respHandler, "xyz.openbmc_project.Dump.Manager",
         std::format("{}/entry/{}", getDumpPath(dumpType), entryID),
         "xyz.openbmc_project.Object.Delete", "Delete");
 }
@@ -706,9 +706,10 @@
             downloadEntryCallback(asyncResp, entryID, dumpType, ec, unixfd);
         };
 
-    crow::connections::systemBus->async_method_call(
-        std::move(downloadDumpEntryHandler), "xyz.openbmc_project.Dump.Manager",
-        dumpEntryPath, "xyz.openbmc_project.Dump.Entry", "GetFileHandle");
+    dbus::utility::async_method_call(
+        asyncResp, std::move(downloadDumpEntryHandler),
+        "xyz.openbmc_project.Dump.Manager", dumpEntryPath,
+        "xyz.openbmc_project.Dump.Entry", "GetFileHandle");
 }
 
 inline void downloadEventLogEntry(
@@ -741,9 +742,10 @@
             downloadEntryCallback(asyncResp, entryID, dumpType, ec, unixfd);
         };
 
-    crow::connections::systemBus->async_method_call(
-        std::move(downloadEventLogEntryHandler), "xyz.openbmc_project.Logging",
-        entryPath, "xyz.openbmc_project.Logging.Entry", "GetEntry");
+    dbus::utility::async_method_call(
+        asyncResp, std::move(downloadEventLogEntryHandler),
+        "xyz.openbmc_project.Logging", entryPath,
+        "xyz.openbmc_project.Logging.Entry", "GetEntry");
 }
 
 inline DumpCreationProgress mapDbusStatusToDumpProgress(
@@ -814,7 +816,8 @@
         return;
     }
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, payload = std::move(payload), createdObjPath,
          dumpEntryPath{std::move(dumpEntryPath)},
          dumpId](const boost::system::error_code& ec,
@@ -1021,7 +1024,8 @@
             "xyz.openbmc_project.Common.OriginatedBy.OriginatorTypes.Client");
     }
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, payload(task::Payload(req)),
          dumpPath](const boost::system::error_code& ec,
                    const sdbusplus::message_t& msg,
@@ -1079,7 +1083,8 @@
 inline void clearDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
                       const std::string& dumpType)
 {
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp](const boost::system::error_code& ec) {
             if (ec)
             {
@@ -1316,7 +1321,8 @@
     }
 
     // Reload rsyslog so it knows to start new log files
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp](const boost::system::error_code& ec) {
             if (ec)
             {
@@ -1851,8 +1857,8 @@
     };
 
     // Make call to Logging service to request Delete Log
-    crow::connections::systemBus->async_method_call(
-        respHandler, "xyz.openbmc_project.Logging",
+    dbus::utility::async_method_call(
+        asyncResp, respHandler, "xyz.openbmc_project.Logging",
         "/xyz/openbmc_project/logging/entry/" + entryID,
         "xyz.openbmc_project.Object.Delete", "Delete");
 }
@@ -2658,7 +2664,8 @@
                                                systemName);
                     return;
                 }
-                crow::connections::systemBus->async_method_call(
+                dbus::utility::async_method_call(
+                    asyncResp,
                     [asyncResp](const boost::system::error_code& ec,
                                 const std::string&) {
                         if (ec)
@@ -3109,9 +3116,9 @@
                         task->payload.emplace(std::move(payload));
                     };
 
-                crow::connections::systemBus->async_method_call(
-                    std::move(collectCrashdumpCallback), crashdumpObject,
-                    crashdumpPath, iface, method);
+                dbus::utility::async_method_call(
+                    asyncResp, std::move(collectCrashdumpCallback),
+                    crashdumpObject, crashdumpPath, iface, method);
             });
 }
 
@@ -3136,8 +3143,8 @@
     };
 
     // Make call to Logging service to request Clear Log
-    crow::connections::systemBus->async_method_call(
-        respHandler, "xyz.openbmc_project.Logging",
+    dbus::utility::async_method_call(
+        asyncResp, respHandler, "xyz.openbmc_project.Logging",
         "/xyz/openbmc_project/logging",
         "xyz.openbmc_project.Collection.DeleteAll", "DeleteAll");
 }
diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp
index 5312950..4814059 100644
--- a/redfish-core/lib/metric_report.hpp
+++ b/redfish-core/lib/metric_report.hpp
@@ -5,6 +5,7 @@
 #include "app.hpp"
 #include "async_resp.hpp"
 #include "dbus_singleton.hpp"
+#include "dbus_utility.hpp"
 #include "error_messages.hpp"
 #include "http_request.hpp"
 #include "logging.hpp"
@@ -116,7 +117,8 @@
                     return;
                 }
                 const std::string reportPath = telemetry::getDbusReportPath(id);
-                crow::connections::systemBus->async_method_call(
+                dbus::utility::async_method_call(
+                    asyncResp,
                     [asyncResp, id,
                      reportPath](const boost::system::error_code& ec) {
                         if (ec.value() == EBADR ||
diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
index 4215b23..06e8075 100644
--- a/redfish-core/lib/metric_report_definition.hpp
+++ b/redfish-core/lib/metric_report_definition.hpp
@@ -840,7 +840,8 @@
                 std::move(sensorParams), metric.collectionFunction,
                 metric.collectionTimeScope, metric.collectionDuration);
         }
-        crow::connections::systemBus->async_method_call(
+        dbus::utility::async_method_call(
+            asyncResp,
             [asyncResp, args](const boost::system::error_code& ec,
                               const sdbusplus::message_t& msg,
                               const std::string& /*arg1*/) {
@@ -958,7 +959,8 @@
         }
     }
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, reportId](const boost::system::error_code& ec,
                               const sdbusplus::message_t& msg) {
             afterSetReadingParams(asyncResp, reportId, ec, msg);
@@ -1025,7 +1027,8 @@
     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, std::string_view id,
     bool enabled)
 {
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, id = std::string(id)](const boost::system::error_code& ec) {
             if (!verifyCommonErrors(asyncResp->res, id, ec))
             {
@@ -1102,7 +1105,8 @@
         recurrenceInterval = static_cast<uint64_t>(durationNum->count());
     }
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, id = std::string(id)](const boost::system::error_code& ec,
                                           const sdbusplus::message_t& msg) {
             afterSetReportingProperties(asyncResp, id, ec, msg);
@@ -1153,7 +1157,8 @@
                                          "ReportUpdates");
         return;
     }
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, id = std::string(id)](const boost::system::error_code& ec,
                                           const sdbusplus::message_t& msg) {
             afterSetReportUpdates(asyncResp, id, ec, msg);
@@ -1202,7 +1207,8 @@
         return;
     }
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, id = std::string(id)](const boost::system::error_code& ec,
                                           const sdbusplus::message_t& msg) {
             afterSetReportActions(asyncResp, id, ec, msg);
@@ -1427,7 +1433,8 @@
 
     const std::string reportPath = getDbusReportPath(id);
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp,
          reportId = std::string(id)](const boost::system::error_code& ec) {
             if (!verifyCommonErrors(asyncResp->res, reportId, ec))
@@ -1541,7 +1548,8 @@
 
     const std::string reportPath = telemetry::getDbusReportPath(id);
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, id](const boost::system::error_code& ec) {
             /*
              * boost::system::errc and std::errc are missing value
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 19f6639..f3a5114 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -7,7 +7,6 @@
 
 #include "app.hpp"
 #include "async_resp.hpp"
-#include "dbus_singleton.hpp"
 #include "dbus_utility.hpp"
 #include "error_messages.hpp"
 #include "generated/enums/resource.hpp"
@@ -284,8 +283,8 @@
     auto callback = [asyncResp](const boost::system::error_code& ec) {
         afterSetNTP(asyncResp, ec);
     };
-    crow::connections::systemBus->async_method_call(
-        std::move(callback), "org.freedesktop.timedate1",
+    dbus::utility::async_method_call(
+        asyncResp, std::move(callback), "org.freedesktop.timedate1",
         "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "SetNTP",
         ntpEnabled, interactive);
 }
diff --git a/redfish-core/lib/openbmc/openbmc_managers.hpp b/redfish-core/lib/openbmc/openbmc_managers.hpp
index 8bd5625..4e726e9 100644
--- a/redfish-core/lib/openbmc/openbmc_managers.hpp
+++ b/redfish-core/lib/openbmc/openbmc_managers.hpp
@@ -7,6 +7,7 @@
 #include "dbus_utility.hpp"
 #include "error_messages.hpp"
 #include "http_request.hpp"
+#include "io_context_singleton.hpp"
 #include "logging.hpp"
 #include "redfish.hpp"
 #include "utils/dbus_utils.hpp"
@@ -591,7 +592,8 @@
 
         BMCWEB_LOG_DEBUG("del {} {}", path, iface);
         // delete interface
-        crow::connections::systemBus->async_method_call(
+        dbus::utility::async_method_call(
+            response,
             [response, path](const boost::system::error_code& ec) {
                 if (ec)
                 {
@@ -1104,7 +1106,7 @@
 
     ~GetPIDValues()
     {
-        boost::asio::post(crow::connections::systemBus->get_io_context(),
+        boost::asio::post(getIoContext(),
                           std::bind_front(&processingComplete, asyncResp,
                                           std::move(complete)));
     }
@@ -1385,7 +1387,8 @@
                 {
                     for (const auto& property : output)
                     {
-                        crow::connections::systemBus->async_method_call(
+                        dbus::utility::async_method_call(
+                            asyncResp,
                             [response,
                              propertyName{std::string(property.first)}](
                                 const boost::system::error_code& ec) {
@@ -1432,7 +1435,8 @@
                         return;
                     }
 
-                    crow::connections::systemBus->async_method_call(
+                    dbus::utility::async_method_call(
+                        asyncResp,
                         [response](const boost::system::error_code& ec) {
                             if (ec)
                             {
diff --git a/redfish-core/lib/redfish_util.hpp b/redfish-core/lib/redfish_util.hpp
index 0b10a1b..ec905dd 100644
--- a/redfish-core/lib/redfish_util.hpp
+++ b/redfish-core/lib/redfish_util.hpp
@@ -4,6 +4,7 @@
 #pragma once
 
 #include "async_resp.hpp"
+#include "boost_formatters.hpp"
 #include "dbus_singleton.hpp"
 #include "dbus_utility.hpp"
 #include "error_messages.hpp"
@@ -100,7 +101,7 @@
         protocolToDBus,
     CallbackFunc&& callback)
 {
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
         [protocolToDBus, callback = std::forward<CallbackFunc>(callback)](
             const boost::system::error_code& ec,
             const std::vector<UnitStruct>& r) {
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 45400dd..d7aeed9 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -2843,7 +2843,8 @@
         "xyz.openbmc_project.Control.Host.NMI";
     constexpr const char* method = "NMI";
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp](const boost::system::error_code& ec) {
             if (ec)
             {
diff --git a/redfish-core/lib/systems_logservices_postcodes.hpp b/redfish-core/lib/systems_logservices_postcodes.hpp
index 2285ab1..cd2cb8c 100644
--- a/redfish-core/lib/systems_logservices_postcodes.hpp
+++ b/redfish-core/lib/systems_logservices_postcodes.hpp
@@ -6,7 +6,6 @@
 
 #include "app.hpp"
 #include "async_resp.hpp"
-#include "dbus_singleton.hpp"
 #include "dbus_utility.hpp"
 #include "error_messages.hpp"
 #include "generated/enums/log_service.hpp"
@@ -123,7 +122,8 @@
     BMCWEB_LOG_DEBUG("Do delete all postcodes entries.");
 
     // Make call to post-code service to request clear all
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp](const boost::system::error_code& ec) {
             if (ec)
             {
@@ -341,7 +341,8 @@
         return;
     }
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, entryId, bootIndex,
          codeIndex](const boost::system::error_code& ec,
                     const boost::container::flat_map<
@@ -377,7 +378,8 @@
     const uint16_t bootIndex, const uint16_t bootCount,
     const uint64_t entryCount, size_t skip, size_t top)
 {
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, bootIndex, bootCount, entryCount, skip,
          top](const boost::system::error_code& ec,
               const boost::container::flat_map<
@@ -534,7 +536,8 @@
         return;
     }
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, postCodeID, currentValue](
             const boost::system::error_code& ec,
             const std::vector<std::tuple<std::vector<uint8_t>,
diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp
index f376752..75e8287 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -954,7 +954,8 @@
         return;
     }
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, id = ctx.id](const boost::system::error_code& ec,
                                  const std::string& dbusPath) {
             afterCreateTrigger(ec, dbusPath, asyncResp, id);
@@ -1052,7 +1053,8 @@
                 const std::string triggerPath =
                     telemetry::getDbusTriggerPath(id);
 
-                crow::connections::systemBus->async_method_call(
+                dbus::utility::async_method_call(
+                    asyncResp,
                     [asyncResp, id](const boost::system::error_code& ec) {
                         if (ec.value() == EBADR)
                         {
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 44c8777d..1e28dda5 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -844,7 +844,8 @@
     const MemoryFileDescriptor& memfd, const std::string& applyTime,
     const std::string& objectPath, const std::string& serviceName)
 {
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp, payload = std::move(payload),
          objectPath](const boost::system::error_code& ec1,
                      const sdbusplus::message::object_path& retPath) mutable {
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index f67af8e9..c312ada 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -501,7 +501,8 @@
     sdbusplus::message::object_path path(
         "/xyz/openbmc_project/VirtualMedia/Legacy");
     path /= name;
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::async_method_call(
+        asyncResp,
         [asyncResp](const boost::system::error_code& ec, bool success) {
             if (ec)
             {
@@ -670,7 +671,8 @@
     // Legacy mount requires parameter with image
     if (legacy)
     {
-        crow::connections::systemBus->async_method_call(
+        dbus::utility::async_method_call(
+            asyncResp,
             [asyncResp](const boost::system::error_code& ec) {
                 if (ec)
                 {
@@ -685,7 +687,8 @@
     }
     else // proxy
     {
-        crow::connections::systemBus->async_method_call(
+        dbus::utility::async_method_call(
+            asyncResp,
             [asyncResp](const boost::system::error_code& ec) {
                 if (ec)
                 {