I have created a JAX-WS client within eclipse that will communicate with a web service that was written in VB.net. I have gotten this to work successfully.
One of my web service methods will return an obect of type KitchenItems[]
The KitchenItems has a bunch of get/set methods for various kitchen properties. However, I cannot access those methods when using KitchenItems[]
Do the brackets convert the object into an array? How can I gain access to the get methods in KitchenItems? I had a test class automatically generated which did the following in order to extract the results:
KitchenItem[] kitchenItem= soap.getKitchenItemsByLoginId(kitchenId);
List list = Arrays.asList(kitchenItem.);
String result = list.toString();
Ideally, I would like to work with the object, and not convert to a string. The above won’t let me convert the array to as a list anyway, as it throws the error:
Type mismatch: cannot convert from List<KitchenItem> to List
Any suggestions? Thanks!
Square brackets on the variable’s type,
KitchenItem[], or on the variable’s name, kitchenItem[], indicate that this variable is an array.The elements of an array are accessed with the square brackets operator where the first element is accessed as
kitchenItem[0]and arrays have alengthfield for determining the number of elements in the array.Assume we have the array of items:
To print the name of the first element in the array:
To print the name of the last element in the array:
One could print all the name of each
KitchenItemwith this code:The array can be turned into a genericized
ListusingHowever the code you have may not be working because of the extra
.on the end or because you have strict checking on in Eclipse. A genericizedListshould be assignable to a simpleList.