RKL eSolutionsBlogs

5 days of Sage X3 Web Services v12 Day 5

Day 5 Consuming X3 Subprogram Web Services from .Net

This is Part 5 of a 5 part series on creating and consuming web services for Sage X3 Version 12. This part will focus on consuming subprogram based web services from .Net. In Part 1 we discussed setup of a Sage X3 Web Services Pool, and in Part 2 we discussed creating and publishing web services based on X3 objects and subprograms, and in Part 3 we discussed using the X3 web services tester to test and evaluate web services, and in Part 4 we discussed calling X3 object-based web services from a .Net program.

Consuming X3 Web Services in .Net

X3 Web Services can be consumed from .net by using the web services WSDL from X3.  Below are the steps to creating a new .Net project to consume X3 web services.  To get started with the solution, instructions on adding the WSDL and creating the authorization class are covered in the blog post for Day 4, which covers creating the initial .net application for web service consumption.

Initialize the Context

Below is a sample .net context initialization.

  • X3 Language - i.e. “ENG”
  • X3 WS Pool – this is the name of the web service pool defined in X3. This may or may not be the same as the endpoint, depending on how it was set up.
  • Context – variable properties are defined here, including the return format (XML or JSON).
  • Web Services Endpoint – this is added to the .config file by default when the WSDL is added to the project, but it can be changed. It should be specified here to override the original definition.
  • Credentials – this is an X3 user. The user must be set up in X3 to allow web services access.
  • Timeout – this can be increased if timeouts are occurring in web service calls.
  • Object Keys – these are required for some types of web service calls, to read/update specific record, etc.

Error Handling

  • The web service resultXML will contain a status of 0 (failed) or 1 (successful)
  • If the status is 0, the error messages will be returned as an array of type CAdxMessage. These can be evaluated for severity, along with the message text.
If the status is 1, the web service was successful. The web service result can be deserialized from an XML or JSON string into a pre-defined class.

Call an X3 Subprogram Web Service

Calling a web service that was published from an X3 subprogram requires use of the “run” method from the web services.  Below is an example of the calling the YWSCUSTLIS subprogram that we created in the Day 2 series.

1. The first step is the initialize the call context and the basic authentication properties.

2. If the status is 1, the web service was successful. The web service result can be deserialized from an XML or JSON string into a pre-defined class.

3. The pre-defined class that the results are deserialized into is shown below.

4. Below is the full code.

Conclusion

You have now learned how to create a .net program to consume a subprogram-based web service.

More in this series (available as they are published)

Day 1 - Creating a Classic SOAP Pool

Day 2 - Creating and Publishing Web Services

Day 3 - Testing Web Services

Day 4- Consuming Web Services in .NET


 

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
Denise Hartman

Written by Denise Hartman

Denise has a B.S. in Business Administration from Millersville University, and an M.B.A. from Loyola University of Maryland and has been working at RKL eSolutions as a Sage Enterprise Management Engineer since 2007. Her main focus is on integrations between third party systems and Sage Enterprise Management. In her free time she enjoys spending time with her husband and adult twin daughters, who are both accountants.

Questions? Need Support?
Get in Touch