RKL eSolutionsBlogs

5 days of Sage X3 Web Services v12 Day 2

Day 2 Creating and Publishing Web Services

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.

Exposing a Sage X3 Object as a Web Service

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
WS2 Sage X3 Object as a Web Service
3. Click the “New” icon on the right.
WS2 new web services

4. Fill in or select the fields as highlighted below.

    • Publication name – this is the web service publication name. This should begin with “Y” or “Z”, indicating it is a partner or customer customization.
    • Description – enter a description for the web service.
    • Type – for objects, select the type of Object. Sub-programs will be covered in the next section.
    • Object – enter the object name for the web service to be published.
    • 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.

WS2 web services setup

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.

WS2 3 step setup

8. After the web service is published, the Publication date will be updated.

WS2 updated publication date

Creating a custom sub-program to call as a web service

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 Subprogram

Create the X3 4GL Source code:

1. From Eclipse, go to File > New > Safe X3 Source File

WS2 X3 4GL Source code

2. Enter the file name and click Finish.

WS2 Create new X3 file

3. Enter the X3 4GL code to select the customers from X3.

WS2 4GL code select customers

4. Compile the code.

Create the X3 Subprogram:

1. From the Sage X3 menu, go to Development > Script dictionary > Scripts > Subprograms

WS2 Create the X3 Subprogram

2. Enter the information as shown below.
    • File – this is the source file name created in Eclipse.
    • Subprogram – enter the subprogram name as it was created in the source file.
    • Description – enter a description for the subprogram
    • Activity code – assign an activity code for the subprogram
    • Module – select the module
    • Web services – this must be checked to create a web service.

WS2 Subprograms

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.
WS2 parameters

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.

WS2 Subprogram setup

6. Enter the web service name and description. The web service name should begin with “Y” or “Z”.

WS2 Name and Description

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.

WS2 Subprogram setup

9. The publication date should be populated, indicating the web service is published and ready for use.WS2 Publication Date

Conclusion

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.

More in this series (available as they are published)

Day 2 - Creating a Classic SOAP Pool


GOT QUESTIONS ABOUT WEB SERVICES FOR SAGE X3?

Contact us if you want to learn more about Sage ERP X3 Web Services features or to request help with your system.

Contact RKL eSolutions

Tagged With: Sage X3

Questions? Need Support?
Get in Touch

Which solution WORKS BEST for your business?

»Take this quiz to find out!

Find the Solution that WORKS BEST for your Business!

close