1

I've got a problem with a web service which has an array or List as parameter. Here is example:

@WebMethod
public String printList(@WebParam(name = "list") List<String> list) {
    String result = "";
    if(list == null) {
        result = "list is null";
    } else if(list.size() == 0) {
        result = "list is empty";
    } else {
        for(String elem : list) {
            result += elem + " ";
        }
    }
    return result;
}

When I call printList from web service client the result is always "list is empty" The same is when I use array of String. Should I use some additional annotations or something?

0

2 Answers 2

2

Your code is perfect, it seems you are calling it wrong way,

and you can remove second condition directly second else will work

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for your answer. If I call some other method of the same web service which for example take one String parameter everything works perfectly - passed String (or long, int or whatever) argument is not null nor empty. So I think I call it correctly. Is there a pssibility that I do something wrong in generating web service?
@Pawel try using SOAP ui once. It seems perfect from server end
life.java It works with soapui - you are right it must be something at the client side. Thanks!
-1

The array datatype in a JAX Webservice is not supportive, so you need to use libraries and tools for such a thing...

1 Comment

The arrays are supported both as a return type and as a web parameter's type when you declare them in your web services but such a web parameter is received as a java.util.List on the client side and the return type becomes YourPrettyObjectArray, calling YourPrettyObjectArray.getItem() returns a java.util.List.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.