1 Reply Latest reply on Apr 18, 2018 10:54 AM by gpgreenleaf

    External Business Object

    gpgreenleaf Rookie

      I'm so lost! For the simplest of use cases, I'm trying to create an external business object that connects to a web service and shows the returned value on my admin dashboard. The web service is a .asmx type that simply return "Hello World":

       

      namespace ServiceStatus

      {

          [WebService(Namespace = "http://tempuri.org/")]

          [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

          [System.ComponentModel.ToolboxItem(false)]

          public class ServiceStatusWebService : System.Web.Services.WebService

          {

              [WebMethod]

              public string HelloWorld()

              {

                  return "Hello World";

              }

          }

      }

       

      Here are some screenshots of the business object, don't know if any of it works:

      bo_details.PNG

      bo_fields.PNG

      bo_form.PNG

      Here is what the script from the web service integration looks like:

       

      // web service call

      console.info("Script starts: ServiceStatus - ServiceStatusWebService - HelloWorld");

       

      methodCall = "HelloWorld";

       

      paramValues = [ null ];

       

      var result1 = serviceInstance.InvokeMethod(methodCall, paramValues);

       

      console.info("Script ends: ServiceStatus - ServiceStatusWebService - HelloWorld");

       

      I've been struggling with the existing documentation! The end goal would be for anyone in a particular role to have a module in their home workspace that displays the operational status of various services. Problem is that I don't know how my web service connects to my business object, nor how the business object connects with a workspace.

        • 1. Re: External Business Object
          gpgreenleaf Rookie

          I did end up creating a solution. I appreciate anyone who at least looked at my question, hopefully my solution helps someone. For my test web service, I tried a basic ASP.NET website, ASMX web service, and RESTful service. The only one that worked was ASMX:

           

          namespace ServiceStatus

          {

              [WebService(Namespace = "http://tempuri.org/")]

              [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

              [System.ComponentModel.ToolboxItem(false)]

           

              [System.Web.Script.Services.ScriptService]

              public class Services : WebService

              {

                  [WebMethod]

                  public Service[] GetAllServices()

                  {

                      Service[] services =

                      {

                          // Test

                          new Service{ ServiceId = 1, ServiceCode = 1 },

                          // Test 2

                          new Service{ ServiceId = 2, ServiceCode = 2 }

                      };

           

                      return services;

                  }

              }

           

              public class Service

              {

                  public int ServiceId { get; set; }

                  public int ServiceCode { get; set; }

              }

          }

           

          Here is the web service integration script:

           

          function Service(id, code)

          {

              this.ServiceId = id;

              this.ServiceCode = code;

          }

           

          // web service call

          console.info("Script starts: ServiceStatus - Services - GetAllServices");

           

          var serviceRef = "Services";

          var serviceCall = "Services";

          var serviceInstance = GetWebService(serviceRef, serviceCall);

          var methodCall = "GetAllServices";

           

          var paramValues = [ null ];

           

          var webMethodResult = serviceInstance.InvokeMethod(methodCall, paramValues);

          var result = [];

           

          for(var i = 0; i < webMethodResult.length; i++){

              result.push(new Service(webMethodResult[i].ServiceId, webMethodResult[i].ServiceCode));

          }

           

          console.info("Script ends: ServiceStatus - Services - GetAllServices");

           

          SynchronizeAllHeatData(HeatContext.BusinessObject.DesignerName, ['ServiceId'], result);

           

          Finally, here are some images of the business object:

           

          bo_details.PNG

           

          bo_fields.PNG

           

          Thanks!

          1 of 1 people found this helpful