SPEL: How to call SDM method using WebServies

Document created by cdtj Champion on Apr 7, 2016Last modified by cdtj Champion on Apr 8, 2016
Version 3Show Document
  • View in full screen mode

Introducing short guide with information consolidated from this community


     Register new method

To register new method new maj file should be created within /site/mods/majic folder, in my example I used api factory without any reason, you can use any factory you want.

Please notice: logged user should have rights to modify objects in selected factory.

// FILENAME: z_api.maj
OBJECT api {
        METHODS {

Method is called z_echo, there is no input arguments specified, ellipsis means that it could receive any amount of attributes.


     Create spel file to execute method

I have used very simple spel which is used to return input attributes back as response.

// FILENAME: z_api.spl
api::z_echo(...) {
    int i;
    for (i=0;i<argc;i++) {
        set_return_data(i, argv[i]);

File should be located in same folder as maj.


     Call method using WebServies

For test purposes I have used SoapUI software which is free and open source, could be downloaded here: SoapUI | Functional Testing for SOAP and REST APIs

Method call:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://www.ca.com/UnicenterServicePlus/ServiceDesk">


Method response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <callServerMethodResponse xmlns="http://www.ca.com/UnicenterServicePlus/ServiceDesk">
         <callServerMethodReturn xmlns=""><![CDATA[<?xml version="1.0" encoding="UTF-8"?>


     Information used

Many thanks to Gutis who provided this useful doc: SPEL API methods

And shared how to return multiple attributes from method: Re: Spel to get array from function

3 people found this helpful