Try OpenEdge Now
skip to main content
Web Services
Creating OpenEdge SOAP Web Services : Sample Code with SOAP Messages for OpenEdge Web Services : Passing static and dynamic ProDataSet parameters : Invoking a method with a DATASET parameter
 
Invoking a method with a DATASET parameter
To invoke a method that passes a DATASET parameter, the client application typically must:
*Create rows using the interface object that represents the TABLE row
*Insert the rows in arrays that represent the constituent temp-tables in the ProDataSet
For example, the following snippet of code passes a ProDataSet parameter represents and operation in the Web service:

getCustOrders.p

/* getCustOrders.p */
DEFINE TEMP-TABLE ttCust NO-UNDO
    FIELD CustNum AS INTEGER
    FIELD Name AS CHARACTER
    INDEX CustNumIdx IS UNIQUE PRIMARY CustNum.

DEFINE TEMP-TABLE ttOrder NO-UNDO
    FIELD OrderNum AS INTEGER
    FIELD CustNum AS INTEGER
    INDEX OrderNumIdx IS UNIQUE PRIMARY OrderNum
    INDEX CustOrdIdx IS UNIQUE CustNum OrderNum.
DEFINE TEMP-TABLE ttOrderLine NO-UNDO
    FIELD OrderNum AS INTEGER
    FIELD LineNum AS INTEGER
    INDEX OrderLineIdx IS UNIQUE PRIMARY OrderNum LineNum.

DEFINE DATASET dsCustOrd FOR ttCust, ttOrder, ttOrderLine
    DATA-RELATION CustOrdRel FOR ttCust, ttOrder
        RELATION-FIELDS (CustNum, CustNum)
    DATA-RELATION OrdLinesRel FOR ttOrder, ttOrderLine
        RELATION-FIELDS (OrderNum, OrderNum) NESTED.

DEFINE INPUT PARAMETER iCustNum AS INTEGER.
DEFINE OUTPUT PARAMETER DATASET FOR dsCustOrd.
/* fill dataset and return to caller */
...
When you add a Web Reference for the CustOrders Web service to Microsoft® Visual Studio, it creates the following proxies in a References file for the getCustOrders operation:

Sample C#.NET proxy code for getCustOrders

public string getCustOrders(
       System.Nullable<int> iCustNum, out dsCustOrd dsCustOrd)
  {
    object[] results = this.Invoke("getCustOrders", new object[] {
      iCustNum});
    dsCustOrd = ((dsCustOrd)(results[1]));
    return ((string)(results[0]));
  }

...

public partial class dsCustOrd {
    private dsCustOrdTtCust[] ttCustField;
    private dsCustOrdTtOrder[] ttOrderField;
    ...
}

...

public partial class dsCustOrdTtCust {
private System.Nullable<int> custNumField;
private string nameField;
    ...
}

...

public partial class dsCustOrdTtOrder {
    private System.Nullable<int> orderNumField;
    private System.Nullable<int> custNumField;
   <!-- nested data relation with ttOrderLine -->
   private dsCustOrdTtOrderTtOrderLine[] ttOrderLineField;
    ...
}

...
public partial class dsCustOrdTtOrderTtOrderLine {
    private System.Nullable<int> orderNumField;
    private System.Nullable<int> lineNumField;
    ...
}
When you reference the Web service in your code, Microsoft Visual Studio offers these proxy objects as appropriate. You can then create code to access the ProDataSet parameter like the following:

Sample C#.NET application for getCustOrders operation

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace getCustOrders
{  class Program
  {
    static void Main(string[] args)
    {
      int iCustNum;
      wsCustOrders.CustOrdersService ws = new
                                          wsCustOrders.CustOrdersService();
      wsCustOrders.dsCustOrd dsCustOrd;
      iCustNum = 1;
      ws.getCustOrders(iCustNum, out dsCustOrd);

      FileStream fs = new FileStream("getCustOrder.out", FileMode.Create);
      StreamWriter w = new StreamWriter(fs);

      //temp-table ttCust
      for (int i = 0; i < dsCustOrd.ttCust.Length; i++)
      {
         w.Write(dsCustOrd.ttCust[i].CustNum);
         w.Write(dsCustOrd.ttCust[i].Name);
         w.WriteLine();
      }
      //temp-table ttOrder
      for (int i = 0; i < dsCustOrd.ttOrder.Length; i++)
      {
        w.Write(dsCustOrd.ttOrder[i].CustNum);
        w.Write(dsCustOrd.ttOrder[i].OrderNum);
        w.WriteLine();
        //nested temp-table ttOrderLine
        for (int j = 0; j < dsCustOrd.ttOrder[i].ttOrderLine.Length; j++)
          {
             w.Write(dsCustOrd.ttOrder[i].ttOrderLine[j].LineNum);
             w.Write(dsCustOrd.ttOrder[i].ttOrderLine[j].OrderNum);
          }
        }
        w.Close();
      }
  }
}
Note: Because .NET has a proprietary method of recognizing and exposing ADO .NET DataSets in WSDL documents, its toolkit cannot translate the WSDL definition of a ProDataSet directly into an ADO .NET DataSet. For an example of creating an ADO .NET DataSet from a ProDataSet parameter, see Creating .NET DataSets from ProDataSet parameters.