Working with data structures
This group of topics describes issues involved in working with data structures.
Commonly Used Elements and Types
This topic describes how Enterprise Service Tools users can include and reference commonly used interface elements (which are derived from COBOL copybooks) using standard XSD and WSDL inclusion mechanisms.
Including and Referencing Commonly Used Elements and Types
It is common in COBOL application development to create reusable sequences of code by putting them into “COPY” files (COPY books) and achieve re-use by including the same COPY book in multiple source files (via the COBOL COPY statement).
Figure 1 is a example of a typical sequence of code to re-use is data definition that repeats in multiple data structures. In this example, the two data definitions re-use the same COPY book named COMMHDR.
01 departmentUpdateRequest.
COPY COMMHDR.
COPY DEPTBDY.
01 departmentUpdateReply.
COPY COMMHDR.
02 updStatus pic xxx.
Figure 2 and Figure 3 show of the content of the COMMHDR copybook and DEPTBDY copybook.
05 commHeader.
10 commId PIC 9(4).
10 commRevDate PIC X(8).
10 commDigest PIC X(40).
2 member-count pic 9(9) binary.
2 dept-details.
3 dept-title pic x(35).
3 dept-id pic x(45).
3 dept-seq pic 9(4).
3 dept-hq pic x(75).
Background for Including and Referencing Commonly Used Elements and Types
Prior to IBM® Developer for z Systems® Version 7.5, service interfaces generated from data structures that referenced COPY books required that complete XML schemas (XSDs) be generated for each data structure.
<schema ...
targetNamespace="http://www.TST01I.com/schemas/TST01IInterface"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:cbl="http://www.TST01I.com/schemas/TST01IInterface">
<complexType name="departmentUpdateRequest">
<sequence>
<element name="commHeader"
type="cbl:departmentupdaterequest_commheader"/>
<element form="qualified" name="member_count">
<simpleType>
...
</simpleType>
</element>
<element name="dept_details"
type="cbl:departmentupdaterequest_dept__details"/>
</sequence>
</complexType>
<complexType name="departmentupdaterequest_commheader">
<sequence>
<element form="qualified" name="commId">
<simpleType>
...
</simpleType>
</element>
<element form="qualified" name="commRevDate">
<simpleType>
...
</simpleType>
</element>
<element form="qualified" name="commDigest">
<simpleType>
...
</simpleType>
</element>
</sequence>
</complexType>
<complexType name="departmentupdaterequest_dept__details">
<sequence>
...
</sequence>
</complexType>
<element name="departmentUpdateRequest" type="cbl:departmentUpdateRequest">
</schema>
<schema attributeFormDefault="qualified"
elementFormDefault="qualified"
targetNamespace="http://www.TST01O.com/schemas/TST01OInterface"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:cbl="http://www.TST01O.com/schemas/TST01OInterface">
<complexType name="departmentUpdateReply">
<sequence>
<element name="commHeader" type="cbl:departmentupdatereply_commheader"/>
<element form="qualified" name="updStatus">
...
</element>
</sequence>
</complexType>
<complexType name="departmentupdatereply_commheader">
<sequence>
<element form="qualified" name="commId">
...
</element>
<element form="qualified" name="commRevDate">
...
</element>
<element form="qualified" name="commDigest">
...
</element>
</sequence>
</complexType>
<element name=" departmentUpdateReply" type="cbl:departmentUpdateReply">
...
</element>
</schema>
- The complex type name for each element:
(departmentupdaterequest_commheader. VS. departmentupdatereply_commheader)
and
- The namespaces for the schemas:
(xmlns:cbl="http://www.TST01I.com/schemas/TST01IInterface. VS. xmlns:cbl="http://www.TST01O.com/schemas/TST01OInterface) .
Because a single COPY book can be used for multiple services the multiplicity of similarly typed elements may lead to unnecessary duplication of code generated for the clients from such WSDL or XSD files.
This feature allows users to specify common COPY book and common XSD types and elements that can be re-used by multiple interfaces without having to have duplicate schema content.
Defining common standard elements and types in generated XSD and WSDL
This topic describes the definition parameters for the feature “Including and Referencing Commonly Used Elements and Types”.
The common schema content is defined to the xsebatch command line tool through an XML file that can be specified either on the command line parameter (-commtypes for “Common Types”) or by the “commTypesFile“ attribute specified in the ServiceSpecification.xml file.
The user can override the commtypes xml file specified with the “commTypesFile“ attribute for input and output message elements (InputMessage and OutputMessage) in the Batch processor option specification file (ServiceSpecification.xml).
When the user creates and specifies the commtypes xml file, the WSDL and XSD generation process uses the information specified in the commtypes file to generate elements, types and schema imports instead of the imbedded types, elements and namespaces. The list of common types from the command line parameter can be overridden by the content of the file(s) specified on the commTypesFile attribute.
| Element or Attribute | Definition |
|---|---|
| CommTypes | Container element for common groups. |
| CommGroup | Group for listing common type information. |
| lang | Specifies the source language of the application source being processed. |
| format | For source languages that permit fixed or free source formatting, this attribute must specify which format is used. Currently this attribute is reserved and set to "fixed". |
| CommonType | Attributes of this element describe how the common application source data items should be processed (see below). |
| srcName | Specifies the source name of the copybook as it appears in the COBOL application program source. COPY books specified in the srcName attribute are not cross-referenced with the COBOL application source files, but they must be present and accessible to the Batch processor tool when the COBOL application source is processed. |
| nativeName | Specifies the COBOL data item name for which the XML schema reference and type should be taken from the common schema. |
| commSchemaLocation | Specifies the common schema location attribute
(xsi:schemaLocation) that is generated in the import statement for
the enclosing WSDL or XSD. Note: For CICS® Webservices
scenarios this location must be accessible when the tools are running,
Otherwise an error message are displayed and the generation process
does not complete.
|
| commNamespace | Specifies the value of the namespace declaration that is generated for referring to the common schema. |
| xmlElementName | Specifies the value of the element name from the common schema that should be referred to from the enclosing WSDL or XSD. |
| commNsPrefix | Specifies the value of the namespace prefix that should be generated to qualify the reference of the common elements and types. |
Figure 6 is an example of a commtype xml file used to direct the processor to use common types, elements, namespaces, in a COBOL source language sample.
<?xml version="1.0" encoding="UTF-8"?>
<commtypes:CommonTypes xmlns:commtypes="http://www.ibm.com/xmlent/commxsd/emf/commtypes">
<commtypes:CommGroup lang="COBOL" format="fixed">
<commtypes:CommonType
srcName="COMMHDR"
nativeName="commHeader"
commSchemaLocation="commHeader.xsd"
commNamespace="http://www.sample.com/schemas/commHeader"
xmlElementName="commHeader"
commNsPrefix="hdr1"
/>
</commtypes:CommGroup>
</commtypes:CommonTypes>
The commtype xml file schema is shown in Figure 7.
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:commtypes="http://www.ibm.com/xmlent/commxsd/emf/commtypes"
targetNamespace="http://www.ibm.com/xmlent/commxsd/emf/commtypes">
<xsd:element name="CommGroup">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="commtypes:CommonType" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="lang" type="xsd:string"/>
<xsd:attribute name="format" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="CommonTypes">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="commtypes:CommGroup"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="CommonType">
<xsd:complexType>
<xsd:attribute name="srcName" type="xsd:string"/>
<xsd:attribute name="xmlElementName" type="xsd:string"/>
<xsd:attribute name="nativeName" type="xsd:string"/>
<xsd:attribute name="commSchemaLocation" type="xsd:string"/>
<xsd:attribute name="commNamespace" type="xsd:string"/>
<xsd:attribute name="commNsPrefix" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Figure 10 shows the commHeader schema.
<schema attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://www.TST01I.com/schemas/TST01IInterface"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:cbl="http://www.TST01I.com/schemas/TST01IInterface"
xmlns:hdr1="http://www.sample.com/schemas/commHeader">
<import namespace="http://www.sample.com/schemas/commHeader"
schemaLocation="commHeader.xsd"/>
<complexType name="departmentUpdateRequest">
<sequence>
<element ref="hdr1:commHeader"/>
<element form="qualified" name="member_count">
<simpleType>
<restriction base="int">
<minInclusive value="0"/>
<maxInclusive value="999999999"/>
</restriction>
</simpleType>
</element>
<element name="dept_details" type="cbl:departmentupdaterequest_dept__details"/>
</sequence>
</complexType>
<schema attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://www.TST01O.com/schemas/TST01OInterface"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:cbl="http://www.TST01O.com/schemas/TST01OInterface"
xmlns:hdr1="http://www.sample.com/schemas/commHeader">
<import namespace="http://www.sample.com/schemas/commHeader"
schemaLocation="commHeader.xsd"/>
<complexType name="departmentUpdateReply">
<sequence>
<element ref="hdr1:commHeader"/>
<element form="qualified" name="updStatus">
<annotation>
<appinfo source="http://www.wsadie.com/appinfo">
<initialValue kind="SPACE"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="string">
<maxLength value="3"/>
</restriction>
</simpleType>
</element>
</sequence>
</complexType>
<element name="employeeUpdateRequest" type="cbl:departmentUpdateReply">
<annotation>
<documentation source="com.ibm.etools.xmlent.batch">8.0.0.V200803251533</documentation>
</annotation>
</element>
</schema>
Figure 10 is an example of the schema for the commonHdr.xsd file.
<?xml version="1.0" encoding="UTF-8"?><schema attributeFormDefault="qualified"
elementFormDefault="qualified" targetNamespace="http://www.sample.com/schemas/commHeader"
xmlns="http://www.w3.org/2001/XMLSchema" xmlns:cbl="http://www.sample.com/schemas/commHeader">
<complexType name="commheader">
<sequence>
<element name="commId">
<simpleType>
<restriction base="short">
<minInclusive value="0"/>
<maxInclusive value="9999"/>
</restriction>
</simpleType>
</element>
<element name="commRevDate">
<annotation>
<appinfo source="http://www.wsadie.com/appinfo">
<initialValue kind="SPACE"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="string">
<maxLength value="8"/>
</restriction>
</simpleType>
</element>
<element name="commDigest">
<annotation>
<appinfo source="http://www.wsadie.com/appinfo">
<initialValue kind="SPACE"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="string">
<maxLength value="40"/>
</restriction>
</simpleType>
</element>
</sequence>
</complexType>
<element name="commHeader" type="cbl:commheader">
<annotation>
<documentation source="com.ibm.etools.xmlent.batch">8.0.0.V200803251533</documentation>
</annotation>
</element>
</schema>
Rules and Conditions
This topic lists the rules and conditions for the feature “Including and Referencing Commonly Used Elements and Types”.
- Content of the common types XML file must match the schema specified in this document. If it does not, the behavior of the Batch processor is unpredictable.
- If common types XML file is specified on the command line and there are common types xml files that are also specified on the commTypesFile attribute, the common types XML file from the command line is overridden by the information from the file(s) specified with the commTypesFile attribute
- If the common types XML file or files are specified (on the command line and/or in the Batch processor options file) but they do not actually exist, the Batch processor issues a warning and proceeds, ignoring the specified file(s).
- If the common types XML file is specified on the commTypesFile attribute for input and output message elements, common element and type information applies only to the InputMessage or the OutputMessage for which the commTypesFile attribute is specified.
- If the common types XML file is specified on the command line or on the commTypesFile attribute but no items are found in the source file that correspond to any itemName specified in the common types XML file, a warning message is issued.
- If common types XML file is specified either on the command line or in the commTypesFile attribute, and GEN_ELEMENT_FORM_QUALIFIED property of the CodeGenProperty attribute is set to false (either in the Batch process configuration file or in the GUI preferences for the workspace) the Batch processor issues a warning and proceeds, ignoring the specified common types XML file(s).
Creation of XML schemas from multiple language structures
This topic introduces multiple-language structure enterprise applications and how the Enterprise Service Tools component can be used to enable them as Web services.
The Enterprise Service Tools batch processor and single-service project Web service wizards allow for generation of XML Schemas from collections of language structures. When enabling an enterprise application as a Web service, it may be that the interface of the application consists of more than one language structure. In order to expose such an application as a service, in a way that is easily consumable by a Web client, the tool supports aggregation of multiple language structures into single, composite XML Schemas for both the request and response message. The process by which this is accomplished depends on whether the batch processor or the Web service wizard is being used. In general, multiple language structures are specified in the order their equivalent XML Schema representations should appear in the composite XML Schema.
An example of a typical application whose interface consists of multiple language structures is an IMS Message Processing Program or MPP. MPP's typically send and receive messages that consist of multiple segments. Each segment is an instance of a language structure. For example, an MPP could expect to receive three segments each being a distinct 01 level language structure: 01 HEADER, 01 BODY, and 01 SUMMARY.
It is also common for multiple instances of a particular 01 level language structure to be present in a message processed or generated by an MPP. For example, multiple instances of the language structure 01 CUSTOMER-RECORD would be placed one after the other in a response to a query that retrieves information about more than one customer.
When enabling an IMS MPP as a Web service, the Enterprise Service Tools batch processor and single-service project Web service wizards generate composite XML Schemas and XML conversion artifacts for the request and response message of an MPP. The combination of the composite XML Schema and XML conversion artifacts provides a highly-consumable Web service interface which relieves the client from having to understand the MPP's complex multisegment runtime message structure.
Specification of multiple request language structures
If an enterprise applications' input interface is comprised of multiple language structures, it is necessary to include each of them in the request message that clients will transmit when the application is invoked as a Web service. To direct the Enterprise Service Tools (EST) Batch processor to incorporate multiple language structures into the XML Schema (XSD) for the request message—specify multiple, sibling, InputMessage elements. The order in which the InputMessage elements are specified determines the order that their equivalent XSD definitions appears in the composite request XSD.
- xmlEleName - name of the XML element mapped to instances of the language structure
- lowerBound - minimum repetitions of the language structure
- upperBound - maximum repetitions of the language structure
Figure 11 demonstrates how to direct the Enterprise Service Tools Batch processor to incorporate multiple language structures when generating the XSD for the request message of a Web service.
<Operation name="PutOrderHistory">
<InputMessage importFile="ORDRSECR.cpy" importDirectory="."
nativeTypeName="ORDRSECR-PUT-HIST-HEAD"
xmlEleName="OrderHistoryHeader" lowerBound="1" upperBound="1">
<ItemSelectionArray>
<ItemSelection itemName="ORDRSECR-PUT-HIST-HEAD.SECURITY-CODE"/>
<ItemSelection itemName="ORDRSECR-PUT-HIST-HEAD.CUSTOMER-ID"/>
<ItemSelection itemName="ORDRSECR-PUT-HIST-HEAD.CUSTOMER-FIRSTNAME"/>
<ItemSelection itemName="ORDRSECR-PUT-HIST-HEAD.CUSTOMER-LASTNAME"/>
</ItemSelectionArray>
</InputMessage>
<InputMessage importFile="ORDRRECS.cpy" importDirectory="."
nativeTypeName="ORDRRECS-HIST-RECORD"
xmlEleName="OrderHistoryRecord" lowerBound="1" upperBound="255">
<ItemSelectionArray>
<ItemSelection itemName="ORDRRECS-HIST-RECORD.ORDER-DATE"/>
<ItemSelection itemName="ORDRRECS-HIST-RECORD.ORDER-ITEM-ID"/>
<ItemSelection itemName="ORDRRECS-HIST-RECORD.ORDER-ITEM-PRICE"/>
<ItemSelection itemName="ORDRRECS-HIST-RECORD.ORDER-ITEM-QTY"/>
<ItemSelection itemName="ORDRRECS-HIST-RECORD.ORDER-ITEM-DESC"/>
</ItemSelectionArray>
</InputMessage>
<OutputMessage ../>
<XseSpec>
<XsdSpecIn xsdEleName="PutOrderHistoryRequest"
targetNamespace="http://www.ibm.com/schemas/weborders"
fileName="PutOrderHistory.xsd"/>
<XsdSpecOut ../>
</XseSpec>
</Operation>
Specification of Multiple Response Language Structures
If an enterprise applications' output interface is comprised of multiple language structures, it is necessary to include each of them in the response message that clients receive when the application is invoked as a Web service. To direct the Enterprise Service Tools Batch processor to incorporate multiple language structures into the XML Schema (XSD) for the response message—specify multiple, sibling, OutputMessage elements. The order in which the OutputMessage elements are specified determines the order that their equivalent XSD definitions appears in the composite response XSD.
- xmlEleName - name of the XML element mapped to instances of the language structure
- lowerBound - minimum repetitions of the language structure
- upperBound - maximum repetitions of the language structure
Figure 12 demonstrates how to direct the Enterprise Service Tools Batch processor to incorporate multiple language structures when generating the XSD for the response message of a Web service.
<Operation name="GetOrderHistory">
<InputMessage ../>
<OutputMessage importFile="ORDRSECR.cpy" importDirectory="."
nativeTypeName="ORDRSECR-GET-HIST-HEAD"
xmlEleName="OrderHistoryHeader" lowerBound="1" upperBound="1">
<ItemSelectionArray>
<ItemSelection itemName="ORDRSECR-GET-HIST-HEAD.CUSTOMER-ID"/>
</ItemSelectionArray>
</OutputMessage>
<OutputMessage importFile="ORDRRECS.cpy" importDirectory="."
nativeTypeName="ORDRRECS-HIST-RECORD"
xmlEleName="OrderHistoryRecord" lowerBound="1" upperBound="255">
<ItemSelectionArray>
<ItemSelection itemName="ORDRRECS-HIST-RECORD.ORDER-DATE"/>
<ItemSelection itemName="ORDRRECS-HIST-RECORD.ORDER-ITEM-ID"/>
<ItemSelection itemName="ORDRRECS-HIST-RECORD.ORDER-ITEM-PRICE"/>
<ItemSelection itemName="ORDRRECS-HIST-RECORD.ORDER-ITEM-QTY"/>
<ItemSelection itemName="ORDRRECS-HIST-RECORD.ORDER-ITEM-DESC"/>
</ItemSelectionArray>
</OutputMessage>
<OutputMessage importFile="ORDRSECR.cpy" importDirectory="."
nativeTypeName="ORDRSECR-HIST-SUMMARY"
xmlEleName="OrderHistoryTail" lowerBound="1" upperBound="1">
<ItemSelectionArray>
<ItemSelection itemName="ORDRSECR-HIST-SUMMARY.TOTAL-ORDERS"/>
<ItemSelection itemName="ORDRSECR-HIST-SUMMARY.TOTAL-SPENT"/>
<ItemSelection itemName="ORDRSECR-HIST-SUMMARY.REPORT-DATE"/>
<ItemSelection itemName="ORDRSECR-HIST-SUMMARY.REPORT-TIME"/>
</ItemSelectionArray>
</InputMessage>
</OutputMessage>
<XseSpec>
<XsdSpecIn ../>
<XsdSpecOut xsdEleName="GetOrderHistoryResponse"
targetNamespace="http://www.ibm.com/schemas/weborders"
fileName="GetOrderHistory.xsd"/>
</XseSpec>
</Operation>
Generation of composite XML schemas from multiple language structures
This topic describes how composite XML Schemas are generated by the Enterprise Service Tools batch processor when multiple language structures are specified for the request and response interfaces of an enterprise application program. The InputMessage and OutputMessage elements of the ServiceSpecification.xml file are used to specify each language structure for the request and response messages respectively.
- Each InputMessage element is processed and the referenced language structure (nativeTypeName) is converted into an equivalent complex type and stored in the request XML Schema. The name of each generated complex type is not settable.
- For each complex type created in step 1, an XML element is defined
and stored in the request XML Schema. The minOccurs and maxOccurs
attributes of each XML element are set to the values of the lowerBound
and upperBound attributes of the corresponding InputMessage element.
The name of each XML element is set to the value of the xmlEleName
attribute in the respective InputMessage element. If the xmlEleName
attribute is not specified or its value is non-unique with respect
to other InputMessage elements, a generated name is used.Note: When the IMS Enterprise Suite SOAP Gateway Web service wizard is used, the xmlEleName attribute is never specified
- Once a complex type and an XML element has been defined for each
language structure, a single, top-level complex type is defined that
contains all the XML elements in the same order as they appeared in
the series of InputMessage elements.Note: When the IMS Enterprise Suite SOAP Gateway Web service wizard is used, the order of the InputMessage element series is determined by the layout specified on the “IMS Message Layouts” page.
- A global XML element is defined whose type is the top-level complex
type created in step 3. The name of the global element is set to the
value of the XsdSpecIn/@xsdEleName attribute.Note: A generated named is used when the xsdEleName attribute is not specified.
Table 2 illustrates the specification of multiple InputMessage elements and the resulting composite XML Schema.
| ServiceSpecification.xml | Composite XML Schema |
|---|---|
|
|
Limitations and Error Conditions
This section describes the batch processor limitations and restrictions on generation of composite XML Schemas from collections of language structures.
Multiple InputMessage and OutputMessages are not allowed if mapping files are specified instead of language source files (that is, meet-in-middle is not supported since this function deals with generation of XSDs).
Multiple InputOutputMessage elements are not supported. Use multiple InputMessage and OutputMessage elements instead.
A language structure may not be specified more than once in a series of InputMessage or OutputMessage elements. This means that an XML Schema complex type derived from a language structure cannot reappear later in an XML message with identical or different field level inclusions and/or exclusions.
All language structures specified on InputMessage and OutputMessage elements (nativeTypeName) must have unique names regardless of the language source file (importFile) they reside in.
All XML element names specified on InputMessage and OutputMessage elements (xmlEleName) must be unique with respective to the other InputMessage or OutputMessage elements. It is not an error to have a XML element name that appears both in a series of InputMessage and OutputMessage elements.
For example, an OCCURS DEPENDING ON (ODO) subject cannot refer to an ODO object in another structure.