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 {
        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="" xmlns:ser="">


Method response:

<soapenv:Envelope xmlns:soapenv="" xmlns:xsd="" xmlns:xsi="">
      <callServerMethodResponse xmlns="">
         <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

0 Favorited
0 Files

Tags and Keywords


Sep 13, 2019 12:54 PM

Using 'spell_object' to return values.

void z_spell_object(...)
	int zi_i;
	send_wait(0, spell_object(),	// @|bop_cmd-#8184|doit|0|0
			"zGetArray",	// method name
			(string)NULL,	// class name (same as class() ?)
			(string)NULL,	// event or macro name (same as event() ?)
			(object)NULL,	// "this" pointer of type object
			'input0',	// input arguments

	for (zi_i=0;zi_i<msg_length();zi_i++) {
		printf("#%d: '%s'\n", zi_i, (string) msg[zi_i]);


void zGetArray(...)
	int zi_i;
	// Returns 'inputs'
	for (zi_i=0;zi_i<argc;zi_i++) {
		set_return_data(zi_i, argv[zi_i]);

	// Returns 'outputs'
	for (zi_i=zi_i;zi_i<argc*2;zi_i++) {
		set_return_data(zi_i, format("output%d", zi_i));

#0: 'input0'
#1: 'input1'
#2: 'input2'
#3: 'output3'
#4: 'output4'
#5: 'output5'

Oct 03, 2017 09:02 AM

It really works. Thank you very much.

May 20, 2016 02:51 PM

This is very nice!!

Thanks for sharing!!!


Apr 08, 2016 06:00 AM

Always great to see people sharing with the communities.

Great job cdtj  and Gutis !!



Apr 07, 2016 09:16 PM

A gold star and a koala stamp for this one!  There are endless possibilities for this, many thanks for sharing this gem.



Apr 07, 2016 05:06 PM

This is awesome. It was on my Todo list,  and you saved me a lot of time. Thanks Timur.

Related Entries and Links

No Related Resource entered.