Describing a string array in a wsdl file

后端 未结 3 1419
孤独总比滥情好
孤独总比滥情好 2021-01-05 22:57

I\'m using the globus toolkit for a project. In my service i have a resource: a string array. I want to get this resource from an Android client. How can I do that? How can

3条回答
  •  遥遥无期
    2021-01-05 23:22

    I guess you're looking for this

    
        
            
        
    
    

    Source: http://www.activebpel.org/samples/samples-2/BPEL_Samples/Resources/Docs/arrays.html

    UPDATE:

    I've done a test using NetBeans 7.0.1. The results were this:

    Declare a method that receives a String[] parameter:

    @WebMethod(operationName = "helloArray")
    public String helloArray(@WebParam(name = "name") String[] name) {
        StringBuilder sb = new StringBuilder("Hello ");
        if (name != null) {
            for(int i = 0; i < name.length; i++) {
                sb.append(name[i]);
                if (i < (name.length - 1)) {
                    sb.append(" and ");
                }
            }
        }
        sb.append('!');
        return sb.toString();
    }
    

    The WSDL generated a complex type for my method with a String array element

    
        
            
        
    
    

    In the client, the IDE generated a List to consume it:

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "helloArray", propOrder = {"name"})
    public class HelloArray {
    
        @XmlElement(nillable = true)
        protected List name;
    
        public List getName() {
            if (name == null) {
                name = new ArrayList();
            }
            return this.name;
        }
    }
    

    And a method to consume the service

    private String helloArray(java.util.List name) {
        edu.home.wsclient.HelloWorldWS port = service.getHelloWorldWSPort();
        return port.helloArray(name);
    }
    

    I've uploaded both projects in this address

提交回复
热议问题