How to use SOAP to communicate with the ICC API
Promet Source recently worked with a national media provider to develop a website from the ground up that was both a highly optimized web property for converting prospective subscribers and a customer portal that would deliver a flawless user experience for existing customers, customer service representatives (CSRs) and retailers.
In this post, we’ll walk through how the Promet Source development team used SOAP (Simple Object Access Protocol) to communicate with the ICC API built for this project.
Client Backend Documentation
The backend for this project uses SOAP to communicate with the ICC API in order to replicate most of the functions of their billing system. During the build process PHPGenerator is used to generate classes from the WSDLs; of each of the endpoints of the ICC API. The class folders can be found in a folder called client/src/ICC/Primitive.
Within each class folder, there is a file named [name-of-class]Service. Within this file, you can find all the available endpoints for the for the class, and the type of parameters each of the endpoints use.
The parameters for each endpoint usually themselves other ICC classes that exist within the class folder, and you will have to recursively open each of the appropriate class files until you find the PHP primitives that make up each of the classes.
In this example we will get the information about an ICC customer.
- Navigate to client/src/ICC/Primitive/Customers
- Open client/src/ICC/Primitive/CustomersService.php
- Find ‘GetCustomer’ from the $classmap array. You may need to use some trial and error to figure out which function you will need to accomplish your goal
- Find the ‘GetCustomer’ implementation. You should see something like this. (The image below shows the file client/src/ICC/Primitive/CustomersService.php)
- You will notice that the GetCustomer function takes in a variable $parameters of type ‘GetCustomer’. You will need to go through the Customers class folder and look for the class file ‘GetCustomer’. You should see something like this (The image below shows the file client/src/ICC/Primitive/Customers/GetCustomer.php)
- The file shows that the GetCustomer object consists of a single php int primitive, and so you are done. You have everything you will need for using the ICC API to get information about a customer. In most cases this process will not be so straightforward. The parameters for the function may consist of a longer hierarchy of objects, and you will have to recursively open the files for each of those objects until you get to the PHP primitives that make up the objects.
- The next thing to do is to make your own Customer class in client/src/ICC like so (The image below shows the file client/src/ICC/Customers.php
- Next you have to build a container for your Customer class. Simply add the following to client/src/ICC/Bootstrap.php like shown below (The image below shows the file client/src/ICC/Bootstrap.php)
- Once the new class and function are complete, test you new function by creating a new file in the client/examples (The image below shows the file client/examples/customersearch.php)
- Once you are sure that your example is working, you can add a new endpoint to the Silex Bootstrap (client/src/Bootstrap.php) and use your new Customer object there. Your new customer object may also be used as part of a larger series of calls to ICC to get more complex information.