NaturalONE Tutorial How to call a Web service from Natural? Recommended Reading • NaturalONE tutorial: How to publish a NaturalONE subprogram as a Web service? 1 Prepare your Eclipse environment 1.1 1.2 Publish a Web service Follow all the steps in tutorial “How to publish a NaturalONE subprogram as a Web service”. However, keep the Web service deployed in the end. I.e. don’t undeploy it as described as the lasts steps of that tutorial. You will use that Web service in a loopback manner in this tutorial. 1.3 1.4 Create a Run Configuration for the XML RPC Server Select the Run drop-down menu in the Eclipse tool bar. Choose Run Configurations… NaturalONE Tutorial – How to call a Web service from Natural?, Page 1|25 1.5 In the Run configurations dialog is opened. Right-click on Java Application to open the context menu. 1.5 Choose New from the context menu. 1.6 A new Run configuration has been created. Name it “EntireX XML RPC Server”. Set the Main class to “com.softwareag.entirex.xml. rt.XMLRPCServer”. NaturalONE Tutorial – How to call a Web service from Natural?, Page 2|25 1.7 Select tab Arguments. Enter 2 lines to the Program arguments. -p C:\NaturalONECE\EntireX\config\entirex.xmlrpcser ver.properties -c C:\NaturalONECE\EntireX\config\entirex.xmlrpcser ver.configuration.xml Hereby “C:\NaturalONE-CE” should be replaced by your NaturalONE community edition installation directory. 1.8 Add “-Dentirex.trace=0” as VM arguments. 1.9 Select tab Classpath. Add 2 additional jar files from within your NaturalONE installation: - …\EntireX\classes\entir ex.jar …\WSStack\lib\wsstackclient.jar NaturalONE Tutorial – How to call a Web service from Natural?, Page 3|25 1.10 Click the Close button to create the configuration. 1.11 Start the newly created EntireX XML RPC Server from the Run menu button. 1.12 Add the XML RPC Server to the RPC Environments 1.13 Open the Preferences dialog via menu Window >> Preferences. NaturalONE Tutorial – How to call a Web service from Natural?, Page 4|25 1.14 Choose Software AG >> EntireX >> RPC Environments. 1.15 Click Insert to create a new RPC Environment. NaturalONE Tutorial – How to call a Web service from Natural?, Page 5|25 1.16 Use Type XML/SOAP RPC Server. Take RPC/XMLSERVER/CALLNAT as Server Address. Press Finish. 1.17 The XML RPC Server now appears on the RPC Environment Monitor. If the monitor is not visible, open the respective view. If the XML RPC Server is not displayed, refresh the monitor with the refresh button. 1.18 Further preparation NaturalONE Tutorial – How to call a Web service from Natural?, Page 6|25 1.19 Within the Travel project, create a new Natural Library “T2OUTBND”. 1.20 Change to the EntireX perspective. NaturalONE Tutorial – How to call a Web service from Natural?, Page 7|25 2 2.1 Extract the Web service information Get the context menu of our Web service application archive GW2_SRV.aar. 2.2 Select Web Services Stack >> View deployed Web Service. 2.3 Copy the URL of the WSDL. NaturalONE Tutorial – How to call a Web service from Natural?, Page 8|25 2.4 On the context menu for T2OUTBND >> RES 2.5 …select New >> IDL Extractor for WSDL. NaturalONE Tutorial – How to call a Web service from Natural?, Page 9|25 2.6 Select “URL” and Press “Next >”. 2.7 Paste the WSDL copied before as “File name”. Press “Next >”. 2.8 Press “Next >”. NaturalONE Tutorial – How to call a Web service from Natural?, Page 10|25 2.9 Press “Next >”. 2.10 Check Transform Unbounded Alphanumeric Fields. Set the Default Field Length to 100. Press “Finish”. NaturalONE Tutorial – How to call a Web service from Natural?, Page 11|25 3 3.1 Download the deployed WSDL Get the context menu of our Web service application archive GW2_SRV.aar. 3.2 Select Web Services Stack >> View Web Services Stack…. 3.3 Click on Services. NaturalONE Tutorial – How to call a Web service from Natural?, Page 12|25 3.4 Scroll to our Web service (GW2_SRV). Right-click on GW2_SRV and download the WSDL (“Save target as” or the like). Save it into the RES folder, besides the .idl and the .xmm. 3.5 Save it into the RES folder, besides the .idl and the .xmm. 3.6 Select the Travel project. Press F5 to refresh the Navigator view from the file system. 3.7 GW2_SRV.xml will appear. Rename it to GW2_SRV.wsdl. This is done via the context menu (right-click). See below. NaturalONE Tutorial – How to call a Web service from Natural?, Page 13|25 3.8 Select Rename…. 3.9 Rename it to GW2_SRV.wsdl. Press OK. NaturalONE Tutorial – How to call a Web service from Natural?, Page 14|25 4 4.1 Deploy the XML mapping Change back to the NaturalONE perspective. 4.2 On the context menu of T2OUTBND >> RES >> GW2_SRV.xmm 4.3 …select Deploy to EntireX XML/SOAP RPC Server. NaturalONE Tutorial – How to call a Web service from Natural?, Page 15|25 4.4 Be sure that you Use an existing RPC Environment for the XML/SOAP RPC Server. This XML/SOAP RPC Server is the part to take your call and transform it into a WS call with the help of the deployed XML mapping file (.xmm). Press Next >. 4.5 Verify that the correct Web service URL appears as a subnode. Verify that the correct XML mapping file appears as another subnode of the Web service URL. NaturalONE Tutorial – How to call a Web service from Natural?, Page 16|25 4.6 Verify that the Target Service URL is correct. Verify that the Mapping Details are correct. Press Finish. NaturalONE Tutorial – How to call a Web service from Natural?, Page 17|25 5 5.1 Generate Natural client code Change back to the NaturalONE perspective. 5.2 On the context menu of T2OUTBND >> RES >> GW2_SRV.idl 5.3 …select Generate Natural from Software AG IDL >> RPC Client… NaturalONE Tutorial – How to call a Web service from Natural?, Page 18|25 5.5 Be sure that you Use an existing RPC Environment for the localhost:1971@NATSRV2800. The localhost:1971@NATSRV2800 is addressing the Natural runtime that is used for the Natural client code generation. In our case this is the local NaturalONE runtime. Press Next >. 5.6 Change the Container to end with SRC instead of RES. You want to place the source files in the SRC folder. Press Finish. 5.7 Verify that 4 files have been generated. Rebuild the project to let the markers/decorators disappear. NaturalONE Tutorial – How to call a Web service from Natural?, Page 19|25 5.8 GW_SRV.NSN: Subprogram that wraps the WS call. GW_SRV2A.NSA: Parameter data area used by the subprogram. GW_SRV2P.NSP: Sample client program to test the Web service consumption. NATRPCL.NSL: Data Area needed by the Natural RPC runtime. NaturalONE Tutorial – How to call a Web service from Natural?, Page 20|25 6 6.1 Test the Web service call Right-click on GW_SRV2P.NSP to open the context menu. 6.2 Select NaturalONE >> Execute. NaturalONE Tutorial – How to call a Web service from Natural?, Page 21|25 6.3 Overwrite the default Server name with XMLSERVER. Press F5. 6.5 Verify that the Web service call has been successful. NaturalONE Tutorial – How to call a Web service from Natural?, Page 22|25 7 Verify, that it is indeed a Web service call and not a local CALLNAT 7.1 Undeploy the Web service. Use the context menu of the T2INBND >> RES >> GW2_SRV.aar file. For a detailed description see, the tutorial “How to publish a NaturalONE subprogram as a Web service?” 7.1 Execute GW_SRV2P.NSP again. Don’t forget to change the server name to XMLSERVER. See the error message when calling the Web service. NaturalONE Tutorial – How to call a Web service from Natural?, Page 23|25 8 8.1 8.2 What happens, if the XML RPC Server is not running? In Eclipse, switch to the Console view. Switch to the EntireX XML RPC Server, if not already visible. Use the Display Selected Console button for this. 8.3 From the menu, choose EntireX XML RPC Server. 8.4 Ensure that you are in the Console view for EntireX XML RPC Server. 8.5 Press the Terminate button. This terminates the EntireX XML RPC Server. 8.6 Switch to the RPC Environment Monitor view. NaturalONE Tutorial – How to call a Web service from Natural?, Page 24|25 8.7 The EntireX XML RPC Server still appears to be running. This is indicated by the green light. 8.8 Press the refresh button. 8.9 The EntireX XML RPC Server is no longer running. This is indicated by the red light. 8.10 Execute GW_SRV2P.NSP again. Don’t forget to change the server name to XMLSERVER. See the error message with a different error code when calling the Web service. NaturalONE Tutorial – How to call a Web service from Natural?, Page 25|25
© Copyright 2024