Kbase P146575: How to invoke an OpenEdge Web Service method with a dynamic ProDataSet output parameter from a .NET
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  21/10/2009 |
|
Status: Unverified
GOAL:
How to invoke an OpenEdge Web Service method with a dynamic ProDataSet output parameter from a .NET client ?
GOAL:
How to invoke an OpenEdge Web Service method with a DATASET-HANDLE output parameter from a .NET client ?
GOAL:
How to consume a DATASET-HANDLE output parameter from an OpenEdge Web Service when using a .NET client ?
FACT(s) (Environment):
OpenEdge 10.1C
OpenEdge 10.2x
All Supported Operating Systems
FIX:
To invoke a method that passes a DATASET-HANDLE parameter:
The client application must create and send an XML Schema along with the data to fully describe the dynamic temp-table in the SOAP request message. The DATASET-HANDLE parameter in a SOAP request or response consists of an XML element containing two child elements:
? An XML schema element representing the schema for the DATASET-HANDLE.
? An XML representation of data, using a data element with child elements representing individual rows for each constituent temp-table.
The client application must parse the XML Schema and data from the SOAP response message to make the DATASET-HANDLE accessible as native data within the application.
This is the general format in OpenEdge Web services for representing a DATASET-HANDLE in a SOAP message:
<DataSet>
<schema ...>
<element ProDataSet>
<!-- TEMP-TABLE-1 definition in XML Schema -->
<!-- TEMP-TABLE-2 definition in XML Schema -->
. . .
</element>
. . .
</schema>
<ProDataSet>
<TEMP-TABLE-1> <!--- row instance 1 --> </TEMP-TABLE-1>
<TEMP-TABLE-1> <!--- row instance 2 --> </TEMP-TABLE-1>
...
<TEMP-TABLE-2> <!--- row instance 1 --> </TEMP-TABLE-2>
<TEMP-TABLE-2> <!--- row instance 2 --> </TEMP-TABLE-2>
...
</ProDataSet>
</DataSet>
For example, the following snippet of code is from a procedure that passes a dynamic ProDataSet parameter:
/* getDynDs.p */
DEFINE INPUT PARAMETER criteria as CHARACTER.
DEFINE OUTPUT PARAMETER DATASET-HANDLE hDset.
/* Create dataset based on criteria
** fill dataset and return to caller */
...When you add a Web Reference for the Web service to Microsoft® Visual Studio, it creates the following proxies in a References file for the getDynDS operation:
public string
getDynDs([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] string criteria, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] out DataSetHandleParam hDset) {
object[] results = this.Invoke("getDynDs", new object[] {criteria});
hDset = ((DataSetHandleParam)(results[1]));
return ((string)(results[0]));
}
...
public partial class DataSetHandleParam {
private System.Xml.XmlElement[] anyField;
...
}
When you reference the Web service in your code, Microsoft Visual Studio offers these proxy objects as appropriate. A dynamic ProDataSet is returned as an array of XMLElement objects (XMLElement[]). The first index (XMLElement[0]) will contain the ProDataSet schema and the second index (XMLElement[1]) will contain the ProDataSet data. You can then create code to access the ProDataSet parameter like the following:
sampleDynDS.sampleDynDSService mySvc = new sampleDynDS.sampleDynDSService();
sampleDynDS.DataSetHandleParam hDataSetOut;
P>mySvc.getDynDs(textBox1.Text, out hDataSetOut);
XmlDocument xmlDocOut = new XmlDocument();
XmlElement xmlSchema = hDataSetOut.Any[0];
XmlElement xmlData = hDataSetOut.Any[1];
xmlDocOut.LoadXml("<hDataSetOut></hDataSetOut>");
XmlElement xmlRoot = xmlDocOut.DocumentElement;
xmlRoot.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
xmlRoot.AppendChild(xmlDocOut.ImportNode(xmlSchema, true));
xmlRoot.AppendChild(xmlDocOut.ImportNode(xmlData, true));
xmlDocOut.Save("C:\\Temp\\dsOutput.xml");.