AMT Help Files

SOAP Header

With Provided Web Services it is possible to use a custom SOAP header.

To use a custom SOAP header, the 'Usage Soap Header' should be set to either 'String', which allows the user to send a single string in the SOAP header to the AMT environment, or 'Class' which allows a multitude of data to be send in the SOAP header to the AMT environment.


The custom SOAP header can only be used in combination with the Document/Literal SOAP style/use.

As an example the following provided web service uses a class as custom SOAP header.

 

This class needs to be an existing class definition, with the exact same name as the class, available in the same repository, see 'Type Class' for more information about classes in AMT.

The example Provided web service uses the following class definition:

begin_definitions

type

    SOAP_HEADER_CLASS : class
      public
      User        : alpha 20
      UserNumber  : numeric 8
      Company     : alpha 20

    end_class

end_definitions

The operations of the Provided web service is no different from provided web services not using a custom SOAP header. For more information see 'Operations'.

 

In the form routine of the Provided web service the custom SOAP header content can be read by using the system item 'SI-SOAPHEADER', which will contain a string or a JSON string of the class data, depending on the choice of SOAP header. In case of a class SOAP header, the JSON string can be used to create an instance of the class filled with data.

 

In the form routine of the example web service this looks as follows:

ROUTINE ROU_SOAP_HEADER_CLASS (UserInput : string) : string
VAR 
SoapHeader_User_data : SOAP_HEADER_CLASS
BEGIN_ROUTINE

// The JSON string containing the user data is used to create a class instance of the 'SOAP_HEADER_CLASS' class definition.
SoapHeader_User_data := SOAP_HEADER_CLASS.FROMJSON (SI-SOAPHEADER)

// This class instance can then be used in the code
result := 'Hello ' & SoapHeader_User_data.USER & '. How are things at ' & SoapHeader_User_data.COMPANY & '? Your input was: ' & UserInput

// It is also possible to change the custom SOAP header data and return that instead.
SoapHeader_User_data.USER := 'AMT Web service'
SoapHeader_User_data.COMPANY := 'Asysco BV'
SoapHeader_User_data.USERNUMBER := 1

// The class with changed data should then be assigned back to SI-SOAPHEADER as a JSON string.
SI-SOAPHEADER := SoapHeader_User_data.
TOJSON ()

END_ROUTINE

 

In SoapUI the Provided webservice with custom SOAP header can be tested.

All the elements of the class definition can be found in the <soapenv:Header> section under the tag containing the 'Soapheader Name' as defined in the Provided web service.

Here is how the example provided web service response looks with the elements filled in: