Property or component
|
Value or name
|
Object type
|
Web service
|
CustOrdersService
|
–
|
URL
|
http://servicehost:80/wsa/wsa1
|
–
|
Session model
|
Session-Free
|
–
|
TargetNamespace
|
urn:CustOrders
|
–
|
WSDL objects
|
CustOrdersObj
|
AppObject
|
dsCustOrd
|
ProDataSet dsCustOrd
|
/* getCustOrders.p */
DEFINE TEMP-TABLE ttCust NO-UNDO FIELD CustNum AS INTEGER FIELD Name AS CHARACTER FIELD Balance AS DECIMAL INDEX CustNumIdx IS UNIQUE PRIMARY CustNum. DEFINE TEMP-TABLE ttOrder NO-UNDO FIELD OrderNum AS INTEGER FIELD CustNum AS INTEGER FIELD OrderDate AS DATE INDEX OrderNumIdx IS UNIQUE PRIMARY OrderNum INDEX CustOrdIdx IS UNIQUE CustNum OrderNum. DEFINE DATASET dsCustOrd FOR ttCust, ttOrder DATA-RELATION CustOrdRel FOR ttCust, ttOrder RELATION-FIELDS (CustNum, CustNum). DEFINE INPUT PARAMETER iCustNum AS INTEGER EXTENT 2. DEFINE OUTPUT PARAMETER DATASET FOR dsCustOrd. DEFINE VARIABLE hq1 AS HANDLE. DEFINE VARIABLE hq2 AS HANDLE. DEFINE VARIABLE lret AS LOGICAL. DEFINE DATA-SOURCE dsCust FOR Customer. DEFINE DATA-SOURCE dsOrder FOR Order. /* fill dataset and return to caller */ CREATE QUERY hq1. hq1:SET-BUFFERS(BUFFER Customer:HANDLE). lret = hq1:QUERY-PREPARE("for each Customer where CustNum >= " + STRING (iCustNum[1]) + " AND CustNum <= " + STRING(iCustNum[2])). DATA-SOURCE dsCust:QUERY = hq1. /* attach the data-sources to the dataset buffers */ BUFFER ttCust:HANDLE:ATTACH-DATA-SOURCE(DATA-SOURCE dsCust:HANDLE,?,?,?). BUFFER ttOrder:HANDLE:ATTACH-DATA-SOURCE(DATA-SOURCE dsOrder:HANDLE,?,?,?). MESSAGE "FILL() " DATASET dsCustOrd:FILL(). |
public string
getCustOrders([System.Xml.Serialization.XmlElementAttribute("iCustNum", IsNullable=true)] 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; private System.Nullable<decimal> balanceField; public partial class dsCustOrdTtOrder { private System.Nullable<int> orderNumField; private System.Nullable<int> custNumField; private System.Nullable<System.DateTime> orderDateField; |
private void button2_Click(object sender, EventArgs e)
{ string result = null; int cntr; int?[] CustNumRange = new int?[2]; CustOrders.dsCustOrd dsCustOrd; CustOrders.CustOrdersService mySvc = new CustOrders.CustOrdersService(); try { CustNumRange[0] = CustNumLow; CustNumRange[1] = CustNumHigh; if (CustNumHigh < CustNumLow) CustNumRange[1] = CustNumRange[0]; result = mySvc.getCustOrders(CustNumRange, out dsCustOrd); |
// Create a .Net Dataset based on this data DataSet x = new DataSet("dsCustOrd"); DataTable t1 = x.Tables.Add("ttCust"); DataTable t2 = x.Tables.Add("ttOrder"); t1.Columns.Add("CustNum", typeof(int)); t1.Columns.Add("Name", typeof(string)); t1.Columns.Add("Balance", typeof(System.Decimal)); t1.Columns[0].Unique = true; t2.Columns.Add("OrderNum", typeof(int)); t2.Columns.Add("CustNum", typeof(int)); t2.Columns.Add("OrderDate", typeof(DateTime)); t2.Columns[0].Unique = true; DataColumn pCol = t1.Columns[0]; DataColumn cCol = t2.Columns[1]; x.Relations.Add(pCol, cCol); |
//Populate the dataset with data from the SOAP message
GetCustOrders.dsCustOrdTtCust[] ttCust = dsCustOrd.ttCust; for (cntr = 0; cntr < ttCust.Length; ++cntr) { Object[] ooCust = new Object[3]; ooCust[0] = ttCust[cntr].CustNum; ooCust[1] = ttCust[cntr].Name; ooCust[2] = ttCust[cntr].Balance; t1.Rows.Add(ooCust); } GetCustOrders.dsCustOrdTtOrder[] ttOrder = dsCustOrd.ttOrder; for (cntr = 0; cntr < ttOrder.Length; ++cntr) { Object[] ooOrd = new Object[3]; ooOrd[0] = ttOrder[cntr].OrderNum; ooOrd[1] = ttOrder[cntr].CustNum; ooOrd[2] = ttOrder[cntr].OrderDate; t2.Rows.Add(ooOrd); } //bind Dataset to Grid myGrid.SetDataBinding(x, "ttCust"); } catch (Exception ex) { MessageBox.Show("getCustOrders Failed: " + ex.Message); } } |