Trading Networks 10.3 | Administering and Monitoring B2B Transactions | webMethods Module for EDI | Creating Clients that Send EDI Documents to Integration Server | Creating the Service the Client Invokes to Handle EDI Documents | Logic to Include in the Service to Form an EDI Document
 
Logic to Include in the Service to Form an EDI Document
The inputs to the service you created depend on the information that the client sends. At a minimum, the service should provide the internal-format document.
The following sample code shows the basic logic you would include to form an EDI document from an internal-format document and send it outbound. For more information about all of the built-in services that the sample uses, see webMethods Module for EDI Built-In Services Reference .
Flow operation
Description
1
Invoke the wm.b2b.edi:convertToValues service to convert the incoming internal-format document, which is either a String or an InputStream, into an IData object. If you want, you can set the input parameters of the convertToValues service to have it validate the structure of the internal-format document. The inputs to the convertToValues service include the internal-format document and the flat file schema that defines the structure of the internal-format document.
For backward compatibility, you can use an IS document type to define the structure of the internal-format document rather than a flat file schema. However, it is recommended that you use flat file schemas.
Note:
If the internal-format document is passed to your service as an IData object, you can still validate its structure before forming the EDI document. See Validating the Input Internal-Format Document When It Is an IData Object.
2
Add your own logic to handle errors that might result from executing the convertToValues service, for example, validation errors.
3
Map data from the internal-format document IData object into the EDI document IData object. Depending on the complexity of your mapping requirements, you might need to add more logic than a MAP flow operation, or create a separate service to perform the mapping.
4
Invoke the wm.b2b.edi:convertToString service to convert the EDI document from an IData object to String format. The inputs to the convertToString service include:
*The IData object that contains the data for your EDI document. Map this IData object to the values input parameter of the convertToString service.
*The flat file schema for the EDI document. The convertToString service uses the flat file schema to determine how to form the EDI document.
For backward compatibility, you can use an IS document type as input to the convertToString service rather than a flat file schema for files with delimited fields and records.
*The type of encoding the convertToString service uses to write data to the output file. When no value is provided for the encoding input parameter, the convertToString service uses the EDIencoding property located in the Integration Server_directory \instances\$instance_name\packages\WmEDI\config\properties.cnf file. When the EDIencoding property is not specified, UTF-8 is used.
For more information about the EDIencoding property, see Defining Module for EDI Properties.
5
Optionally, invoke the convertToValues service against the EDI document to validate the structure of your final EDI document. The inputs to the convertToValues service include:
*The EDI document. The string output parameter of the convertToString service contains the EDI document. Map this to the edidata input parameter of the convertToValues service.
*The flat file schema that defines the structure for the EDI document.
6
If needed, add the group envelope to the EDI document by invoking either the wm.b2b.edi.util:addICEnvelopeEDIFACT service if you are creating a UN/EDIFACT EDI document or the wm.b2b.edi.util:addGroupEnvelope service if you are creating another kind of EDI document.
For more information about adding UN/EDIFACT envelopes, see Adding UN/EDIFACT Envelopes.
7
Add the interchange envelope to the EDI document by invoking either the wm.b2b.edi.util:addICEnvelopeEDIFACT service if you are creating a UN/EDIFACT EDI document or the wm.b2b.edi.util:addICEnvelope service if you are creating another kind of EDI document. For more information about adding UN/EDIFACT envelopes, see Adding UN/EDIFACT Envelopes.
8
Add your own logic or invoke a service that you create to send the EDI document outbound.