CA Service Management

 View Only

SPEL: How to call SDM method using WebServies 

Apr 07, 2016 11:20 AM

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 {
    FACTORY {
        METHODS {
            z_echo(...);
        };
    };
};

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">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:callServerMethod>
         <sid>1141608663</sid>
         <methodName>z_echo</methodName>
         <factoryName>api</factoryName>
         <formatList></formatList>
         <parameters>
            <string>Hello</string>
            <string>World</string>
   <string>!!!</string>
         </parameters>
      </ser:callServerMethod>
   </soapenv:Body>
</soapenv:Envelope>

 

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">
   <soapenv:Body>
      <callServerMethodResponse xmlns="http://www.ca.com/UnicenterServicePlus/ServiceDesk">
         <callServerMethodReturn xmlns=""><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<ServerReturn>
<Param0>Hello</Param0>
<Param1>World</Param1>
<Param2>!!!</Param2>
</ServerReturn>]]></callServerMethodReturn>
      </callServerMethodResponse>
   </soapenv:Body>
</soapenv:Envelope>

 

     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

Statistics
0 Favorited
37 Views
0 Files
0 Shares
0 Downloads

Related Entries and Links

No Related Resource entered.