Kbase P8484: Dynamics and XML Support
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/15/2008 |
|
Status: Unverified
GOAL:
Dynamics and XML Support
GOAL:
Dynamic B2B, SmartProducer, SmartConsumer, and SonicMQ 4GL Adapter
FACT(s) (Environment):
Dynamics
Progress 9.1D
Progress 9.1C
FIX:
The purpose of this Solution is to illustrate the functionality of the dynamic objects used in B2B communications, using the SonicMQ 4GL adapter, SmartProducer, SmartConsumer, and a dynamic browse.
Scenario
You have been tasked with designing a simple interface for transferring the current customer?s information from one computer screen to another, via Java and XML.
Solution overview
When finished, you will have two windows, one to send and one to receive.
Requirements
You must:
 Start a server for the sports2000 database.
 Have SonicMQ installed on your machine, and the broker up and running, or be able to connect to a running SonicMQ broker on a different machine.
 Have an AppServer partition defined (you may reuse the ones defined for the sample Application: sports2000partition). If you set this partition to remote, you must start the corresponding AppServer broker supporting the Application Service associated with your partition.
 Have a JMS Server partition defined (you may reuse the ones defined for the sample Application: jms1). For any JMS Server partition you use set the appropriate value to the broker URL property corresponding to the SonicMQ broker you will connect to.
 Once your SonicMQ broker is up and running, start your SonicMQ Adapter from the Progress Explorer.
1. Create XML mapping files for the SmartProducer and the SmartConsumer based on the customer.xsd file. Save these files as:
 customer.xmp for the message producer
 customer.xmc for the message consumer
2. Create a Sending window with the following components:
 The dcustomer.w SDO
 A dynamic SmartB2B object configured as a producer using the customer.xmp file
 A SmartProducer
 A dyamic browse
 A button to send the message
3. Create a Receiving window with the following components:
 The dcustomer.w SDO
 A dynamic SmartB2B object configured as a consumer using the customer.xmc file
 A SmartConsumer configured to talk to the SonicMQ broker
 A dyamic browse
 A SmartPanel for navigation
4. Optional extra:
 Put the sender and the receiver on different machines.
Detailed Steps:
Section 1: Create the XML mapping files for the SmartConsumer and SmartProducer
1. Open PRO*Tools.
a. Choose the XML Schema Mapping Tool.
b. Open the customer.xsd file.
You should see a screen similar to the following, which is the visual representation of the customer information that is included in the XML Schema file:
You need two files, one to produce the XML message, and one to interpret it.
2. Create the XML file that will produce the message
In order to link the XML to your data, you need to add the customer SDO into the available object list.
a. Select the Object tab, and click add.
b. Browse to the dcustomer.w file, and open it.
c. Choose the Producer mode. You should see the following screen:
d. You need to tell XML which SDO fields are going to be mapped to which XML elements. Return to the Map tab, which should generate the following screen:
e. Map each field in the SDO to the elements in the XML.
i. Select the element in the tree view, (for example: Salesrep).
ii. Select its corresponding field in the SDO, and click Map.
iii. Do the same for the remainder of the fields. The completed mapping should looks like the following:
f. This file is for the production of the message, so save it as customer.xmp (?producer?).
3. Create the XML file that will receive and interpret the message
a. Using the currently open file, click the Object tab.
b. Change mode to consumer, and return to the map tab.
c. Se.lect the object radio button, and highlight the Customer element from the tree view.
d. Map this to the update (may exist) function, and you will now have a completed consumer file that should look exactly like the following:
4. Save this as customer.xmc. (?consumer?).
Section 2: Create the Sending window
The sending window will consist almost entirely of dynamic objects, with the exception of the SDO.
1. Create a new Smart Window.
2. Drop on an instance of the dcustomer.w SDO.
3. Add a dynamic SmartB2Bobject by right clicking the SmartB2BObject icon on the palette, see icon below.
4. Open the property sheet for the B2B and click edit.
Note: this application is case sensitive.
As this is the producer you need to configure the options using the customer.xmp file, which was generated in the previous section.
a. Use customer.xmp as the XML Mapping File..
b. Destination is the topic of the Sonic message to be sent between B2B?s. The receiving application must be listening for the same topic that is entered here. Enter ?TestXML? as in the following example:
c. Add the smart producer.
d. Accept the link to the dynamic B2B
e. Open the instance properties, and configure it to talk to the sonic broker.
5. Set the JMS partition.
6. Set the type of message to be sent.
7. In this example, select to transfer the raw bytes of the message.
Note: The JMS fields on the right are only required if security has been set up. This example is not using JMS security.
When you are finished the dialog should look similar to the following:
a. Add a dynamic browse to the window by right clicking the SmartDataBrowser icon from the palette.
b. Drop it on the window, and accept the default links from the Advisor.
c. Create a button on the window.
d. Add the following code to the ON-CHOOSE trigger:
RUN SendMessage IN h_dynb2b.
e. Change the label of the button to read, ?Send?
f. Close and save the window as wXMLFrom.w. The final window should look similar to this:
Section 3: Create the Receiving window
As with the sending window, the receiving window will consist almost entirely of dynamic objects.
1. Create a new Smart Window.
2. Drop on an instance of the dcustomer.w SDO.
3. Add a dynamic SmartB2Bobject by right clicking the SmartB2BObject icon on the palette.
4. Bring up the property sheet for the B2B and click edit.
As this is the consumer, you need to configure the options using the customer.xmc file, which was generated in the first section.
5. Add the customer.xmc into the property box as illustrated below:
6. Add the smart consumer.
7. Accept the link to the Dynamic B2B.
8. Open the instance properties, and configure it to talk to the Sonic broker.
a. Set the JMS partition to listen on.
b. Add a destination record. This will tell the consumer exactly what it should be listening for. Make sure you enter the same information (i.e. ?TestXML?) as you did when creating the sending window.
When you are finished the dialog should look similar to the following:
9. Add a dynamic browse to the window, by right clicking the SmartBrowser icon from the palette.
a. Accept the default links from the Advisor.
10. Add a Smart Panel for navigation to this window.
a. Accept the default links from the Advisor.
11. Close and save this window as wXMLTo.w. When you are finished, your window should look similar to the following:
Section 4: Running the application
1. Start two AppBuilder sessions, each connected to the sports2000 database.
a. Run wXMLFrom.w on one session.
b. Run wXMLTo.w on the second session.
c. Select a record from the browse on the sending window, and click Send. The selected record on the receiving window should al.so synchronize.
Bonus:
Run the sender and receiver applications on different machines.
1. The Receiver must have:
a. A copy of the .xmc file.
b. The IP address or host name of the Sender.
2. The Sender does not need to be modified..