cancel
Showing results for 
Search instead for 
Did you mean: 

Returning table structure from Web Service...

Former Member
0 Kudos

Hi,

I have a web service which retrieves data from a database table. I want to use this web service from my Visual Composer to display the data on the screen.

I want to know how to return the table structure from my web service. Currently i am returning a string array (only one row of data) from my web service and displaying it in the VC. But i want to include the names of the columns as well.

I tried using 2D String[] and HashMap, both didn't work for me.

Any ideas?

Regards,

Venkat

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Venkat,

I recommend to pass the headers in seperat variables and the data table in a array.

I did something similar, without the header, because they are fixed in my scenario.

This webservice returns a list of all Portal Roles:


	public roleModel[] getRoles() throws Exception{
			// Array List as return value
			ArrayList RoleList = new ArrayList();
			// Try Block reading portal roles
			try {
				IRoleFactory rfact = UMFactory.getRoleFactory();
				// Filter for PortalRoles
				IRoleSearchFilter roleFilter = rfact.getRoleSearchFilter();
				// Search for *
				roleFilter.setUniqueName("*", ISearchAttribute.EQUALS_OPERATOR, false);
				// Search all Roles
				ISearchResult resultList = rfact.searchRoles(roleFilter);
				// return the result list
				if (resultList.getState() == ISearchResult.SEARCH_RESULT_OK) {
					while (resultList.hasNext()) {
						// read roleUid 
						String roleUid = (String) resultList.next();
						// create roleObject for roleUid
						IRole roleObject =	rfact.getRole(roleUid);
						//  instantiate new role for  ArrayList
						roleModel rolle = new roleModel();
						// read DisplayName and UniqeID 
						rolle.setRole(roleObject.getDisplayName());
						rolle.setRoleID(roleObject.getUniqueID());
						rolle.setDescription(roleObject.getDescription());
						// add object to ArrayList
						RoleList.add(rolle);
					}
				}
				// create new array from data type model roleModel (class)
				// in the correspoding size
				roleModel[] returnList = new roleModel[RoleList.size()];
				// write ArrayList back to array
				RoleList.toArray(returnList);
				// return all portal roles
				return returnList;
			// exception handling
			} catch (Exception e) {
				throw new Exception(e);
			}
	}

Hope that helps!

Best Regards,

Marcel

former_member193545
Active Participant
0 Kudos

Hi

I am not to familiar with java, but I suppose you have to return an array of objects.

Jarrod Williams