This is Part 2 of a 5 part series on creating and consuming web services for Sage X3 Version 12. This part will focus on creating web services. In Part 1 we discussed setup of a Sage X3 Web Services Pool.
Many Sage X3 objects can be exposed as a web service. Below are the steps on how to do this.
1. Log on to the Sage X3 web client.
2. Navigate to Development > Script dictionary > Scripts > Web services
3. Click the “New” icon on the right.
4. Fill in or select the fields as highlighted below.
Transaction – if the object is transaction-based, the transaction must be selected. Since the number of fields for web services is limited, if too many fields are published, an error will occur. To limit the number of fields published for the web service, select a transaction that has minimal fields enabled.
5. Click the “Create” icon on the right. A message will appear indicating the web service has been created.
6. Click the "Save" icon on the right.
7. After the web service is created and saved, the “Publication” button will be enabled. Click the “Publication” button.
8. After the web service is published, the Publication date will be updated.
Custom subprograms can also be created and be called as a web service. The example below retrieves a list of customers that were updated in the past n days.
Create the X3 4GL Source code:
1. From Eclipse, go to File > New > Safe X3 Source File
2. Enter the file name and click Finish.
3. Enter the X3 4GL code to select the customers from X3.
4. Compile the code.
1. From the Sage X3 menu, go to Development > Script dictionary > Scripts > Subprograms
Web services – this must be checked to create a web service.
3. Scroll down to the Parameters section at the bottom of the page. When the subprogram is first created, the Dim values will all default to 1. This represents the number of array elements that can be returned in the web service call. Since we specified up to 100 in the subprogram source, the Dim value for each return field (Argument type of Address) must be changed to 100, as shown below.
4. Click the Create icon.
5. The subprogram is now defined in X3. To create a web service for this subprogram, click the Publication button at the top of the screen.
6. Enter the web service name and description. The web service name should begin with “Y” or “Z”.
7. Click the Create icon.
8. The subprogram is now defined in X3. To create a web service for this subprogram, click the Publication button at the top of the screen.
9. The publication date should be populated, indicating the web service is published and ready for use.
The object based web service and subprogram based web service are now ready for consumption using any programming language, such as C#, Java or PHP.
Day 1 - Creating a Classic SOAP Pool
Day 2 - Creating and Publishing Web Services
Day 4- Consuming Web Services in .NET
Day 5 - Consuming X3 Subprogram Web Services from .Net
Contact us if you want to learn more about Sage ERP X3 Web Services features or to request help with your system.