Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Work Tasks

How to Use a Web Service or Remote Service using SOA Infrastructure?

How to Use a Web Service or Remote Service using SOA Infrastructure?

  • Last UpdatedJun 10, 2024
  • 5 minute read

This example illustrates how to use a web service or remote service using SOA infrastructure. The example is a very simple one which can be modified to have a more practical scenario.

PROCEDURE

NAMESPACE USED

System

System.Web

System.Web.Services

System.Web.Services.Protocols

To create a New Web Service

  1. On the Windows Start menu, point to All Programs, and then click Microsoft Visual Studio. The Visual Studio Start Page appears.

  2. In the File menu, point to New, and then click Web Site. The New Web Site dialog box appears.

  3. In the Templates pane, select ASP.NET Web Service. This is selected by default, and you can retain the default.

  4. Enter a name for the website by changing the default name in the Location text box, for example, M:\Work\WebSite8. You can retain the default selection of File System in the Location drop down.

  5. Click OK.

    Sample Code for creating Web service using System;

    using System.Web;

    using System.Web.Services;

    using System.Web.Services.Protocols;

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

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

    public class Service : System.Web.Services.WebService

    {

    public Service ()

    {


    //Uncomment the following line if using designed components

    //InitializeComponent();

    }


    [WebMethod]

    public string SkeltaTest()

    {

    return "This is my SketlaTest";

    }

     

    }

To create a Web Site

Complete the following steps to create a web site to host the created web service:

  1. Open IIS Manager.

    • For Windows Server 2012, on the Start page click the Server Manager tile, and then click OK. In the Server Manager, click the Tools menu, and then click Internet Information Services (IIS) Manager.

    • For Windows 8.1, on the Start page type Control Panel, and then click the Control Panel icon in the search results. On the Control Panel screen, click System and Security, click Administrative Tools, and then click Internet Information Services (IIS) Manager.

  2. In the Connections pane, right-click the Sites node in the tree, and then click Add Website.

  3. In the Add Website dialog box, enter a friendly name for your website in the Site name box.

  4. If you want to select a different application pool than the one listed in the Application Pool box, click Select. In the Select Application Pool dialog box, select an application pool from the Application Pool list and then click OK.

  5. In the Physical path box, enter the physical path of the website's folder, or click the browse button to navigate the file system to find the folder.

  6. If the physical path that you entered in the previous step is to a remote share, click Connect as to specify credentials that have permission to access the path. If you do not use specific credentials, select the Application user (pass-through authentication) option in the Connect As dialog box.

  7. Select the protocol for the website from the Type list.

  8. If you must specify a static IP address for the website (by default, this is set to All Unassigned), enter the IP address in the IP address box.

  9. Enter a port number in the Port text box.

  10. Optionally, enter a host header name for the website in the Host Header box.

  11. If you do not have to make any changes to the site, and you want the website to be immediately available, select the Start Web site immediately check box.

  12. Click OK.

    Creating Proxy dll

    We have to create a Proxy dll since the proxy does all the marshalling and serialization/deserialization of parameters and returns to/from a web service.

    Creating proxy dll using WSDL

    Create the proxy class of the web service using the WSDL tool. Use the wsdl.exe utility to generate code for XML web service clients and XML web service using ASP.NET from WSDL contract files, XSD schemas, and discomap discovery documents. This tool can be used in conjunction with disco.exe.

    In Visual Studio Command Prompt, run the following command:

    C:\Program Files\Microsoft Visual Studio\VC> wsdl /namespace:SkeltaSOAWebProxy http://localhost:1508/WebService_New/MyWebService.asmx?wsdl 
     

    To create proxy dll using CSC command

    1. Create DLL using CSC command.

    2. Create a new project 'SOAWebServiceUse'.

    3. Right-click 'SOAWebServiceUse' project which created and click Add Reference.

    4. Add reference 'SkeltaSOAService.Dll' to use.

      Place this compiled proxy class in the dll and refer the same from where you want to access the Web Service.

      Create a .net Assembly to consume the Web Service method.

      using System;

      using System.Collections.Generic;

      using System.Text;

      using SOAWebProxy;


      namespace SOAWebSeriveUsage

      {

      public class SOAWebSeriveUsage

      {

      public SOAWebSeriveUsage() { }

      public string GetWebServiceData()

      {

      SOAWebProxy.Service ser = new SOAWebProxy.Service();

      return ser.SkeltaTest();

      }

      }

      }

      Do not forget to add the Proxy.dll in the reference.

      Figure - Solution Explorer

      Adding New SOA Folder

      The very basic component of SOA repository is the Folder. Basically you need to register a folder to consume the assemblies from the folder. Add the reference folder into the SOA Folders.

      Adding new folder in the SOA Folder option:

      1. Go to Start > All Programs > AVEVA > Work Tasks > Central Configuration.

      2. Go to the Repository List.

      3. Click Site Path from which you would like to login to the repository. This redirects to the Enterprise Portal.

      4. Click arrow button to enter into the Enterprise Console.

      5. In the Enterprise Console, enter the User Name and Password. Click the icon next to the Password field to login.

      6. From the Enterprise Console menu, select Tools > SOA Assembly.

      7. In the ribbon bar, click New Folder.

      8. In the Title text box, enter the folder name as 'MySkeltaTest'.

      9. In the Description text area, enter a description for the folder.

      10. In the Physical Path text box, enter the physical path to verify the presence of the assembly using the view assembly option.

      11. Click Verify Assemblies.

      12. Click Save.

        Adding Assembly

        There are two options to add assembly into the SOA repository i.e. From GAC or From Assembly Folder.

        To add an assembly in the SOA repository, choose the SOA > Assemblies option from the Enterprise Console.

        Note:

        - If the web service is not available, the system shows the warning message:
        “Unable to access < Web service url>. The web service call will be ignored for further processing. Exception message ...".
        The methods consumed in the Workflow will not be executed.

        - After upgrading the product, validation may not happen when you click on View Code or OK button in the Expression Editor. If you get an "Access Denied" message in the Logger Console, delete the SOA Web service dll from the Windows Temp folder and access it again.

        - If the SOA Execute activity configured with SOA Web service is not working, you need to delete that activity and reconfigure it.

        In This Topic
        Related Links
        TitleResults for “How to create a CRG?”Also Available in