cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with displaying array or list returned by a web service

Former Member
0 Kudos

Issue: How to specify in VC that all the elements of an array or list returned by a web service should be displayed

Description:

I have created a web service getArray() that returns String[]. I have tested this web service and it works. I have added it in VC and dragged the getArray() method to the storyboard and created an output table. When testing the iView only the first element is displayed, not all the elements.

According to this post https://www.sdn.sap.com/irj/sdn/wiki?path=/display/vc/outputfieldnotseenas+array& there should be a "Add Fields" button when I click on Test Data Service, however I do not see it.

Help would be very much appreciated. Thank you.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Charisse,

you have to create an own class, e.g.

public class returnStringClass implements Serializable {

private String YourReturnValue;

public String getYourReturnValue() {

return YourReturnValue;

}

public void setYourReturnValue(String string) {

YourReturnValue = string;

}

}

then in your bean you have to add an ArrayList:

public returnStringClass[] yourBean() throws Exception{

// ArrayList

ArrayList StringList = new ArrayList();

// You can do this in a loop

// new instance of the helpclass

returnStringClass helpClassInstance = new returnStringClass();

helpClassInstance.setYourReturnValue("YOUR STRING");

StringList.add(helpClassInstance);

// You have filled your List in a loop then return it as returnvalue

// Great an Array with the correct size

returnStringClass[] returnList = new returnStringClass[StringList.size()];

// ArrayList pass to your created Array

StringList.toArray(returnList);

// return you return list

return returnList;

}

This should work with VC, I have done it with a portal service. I'm looking forward to write a blog about this service and how to use it with VC in the next weeks if you want and I think this would be a good one for other VC users.

Best Regards,

Marcel

Former Member
0 Kudos

Thank you for your response, Marcel. I followed your example and it worked.

However when my custom bean class has two String attributes, aString and bString, only the first is displayed. When I test the web service using the Web Services Navigator in NWDS, it correctly displays both attributes.

So now all the elements are being displayed, but only for the first attribute. Is there an extra step that needs to be done?

Former Member
0 Kudos

Hi Marcel,

I have followed your tutorial on Portal Webservice for getting portal roles in Visual Composer part I - a great article which I have implemented yesterday.

However, I have some differences :

1) The WebServices navigator doesn't return a tree showing all the values like in your screenshot, I get the following responses instead :

a) GetAllPortalRoles

response (test.types.GetRolesResponse)

HTTP/1.1 200 OK

Connection: close

Set-Cookie: <value is hidden>

Set-Cookie: <value is hidden>

Server: SAP J2EE Engine/7.00

Content-Type: text/xml; charset=UTF-8

Date: Tue, 12 Feb 2008 11:13:12 GMT

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ><SOAP-ENV:Body><rpl:getRolesResponse xmlns:rpl='urn:GetAllPortalRolesVi'></rpl:getRolesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

-> The NW Dev Studio debugger returns twice an array : 0...99 and 100 - 120

In the Visual Composer, the Data Service dragged into the iView only has in 'input', no 'ouput'.

b) GetAllPortalRolesForUser

response (test.types.GetPortalRolesForUserResponse)

Response (String) [Ljava.lang.String;@50a42015

HTTP/1.1 200 OK

Connection: close

Server: SAP J2EE Engine/7.00

Content-Type: text/xml; charset=UTF-8

Date: Tue, 12 Feb 2008 11:15:33 GMT

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ><SOAP-ENV:Body><rpl:getPortalRolesForUserResponse xmlns:rpl='urn:GetRolesForUserVi'><rpl:Response>[Ljava.lang.String;@50a42015</rpl:Response></rpl:getPortalRolesForUserResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

-> I have switched on the debugger in the NW Developer Studio and 'returnList' is an array filled up with all roles, their description etc.

2) The visual composer table doesn't display the array contents, as a result of b) I only see in the table [Ljava.lang.String;@50a42015

3) We are using NW 2004s SP13

Any ideas?

Many thanks!

Former Member
0 Kudos

Okay, solved some issues

1) The WebServices navigator doesn't return a tree showing all the values like in your screenshot

-> I have edited the Virtual Interfaces files (GetAllPortalRolesVi and GetRolesForUserVi) : I removed & added the methods (getRoles and getRolesForPortalUser) - now the appropropriate incoming & outgoing parameters are added, as well as the exceptions

Now the issues left :

a) GetAllPortalRoles

In the Visual Composer, the Data Service dragged into the iView only has in 'input', no 'ouput'

b) GetAllPortalRolesForUser

The visual composer table doesn't display ANY contents when the userID is filled in and the search button pressed. When debugging using NW Developer studio, the correct info is returned.

Thanks again for the help -

Former Member
0 Kudos

Ok, issues solved, everything works! Apparently it had to do with the caching of the visual composer data sources.

On the Wiki link [Visual Composer Caching data source|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/vc/cachingdatasource&] there is a par file that can be deployed to clear the visual composer cache.

Former Member
0 Kudos

hi

try to add output of this web service to a dropdown(dynamic entry list) and check , are you getting all the enteries.

Thanks & Regards

Harsimran