English 中文(简体)
a. 铺设一个护卫阵
原标题:Describing a string array in a wsdl file

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 I describe in the wsdl file the type "array of string"? Thank you.

最佳回答

我猜想你重新研究这一问题。

<complexType name= ArrayOfString >
    <sequence>
        <element name= item  type= xsd:string  maxOccurs= unbounded />
    </sequence>
</complexType>

资料来源:

最新资料:

我先使用NetBeans 7.0.1进行测试。 结果是:

2. 申报一种收取固定参数的方法:

@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();
}

WSDL在我的方法中产生了一种复杂的类型,它包含一个阵容要素。

<xs:complexType name="helloArray">
    <xs:sequence>
        <xs:element name="name" type="xs:string" nillable="true" minOccurs="0" 
            maxOccurs="unbounded"/>
    </xs:sequence>
</xs:complexType>

在客户中,民主选举学会生成了一个<代码>List<String>,用于消费:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "helloArray", propOrder = {"name"})
public class HelloArray {

    @XmlElement(nillable = true)
    protected List<String> name;

    public List<String> getName() {
        if (name == null) {
            name = new ArrayList<String>();
        }
        return this.name;
    }
}

And a method to consume the service

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

I ve uploaded both projects in this address

问题回答

您可以使用一种具有强硬成分的习俗类型(如果你喜欢的话,则会增加数据);

<xsd:sequence>
  <xsd:element name="YourClass" type="pre:YourClass" maxOccurs="unbounded" minOccurs="0">
  </xsd:element>
</xsd:sequence>

• X X children children children children children children children children

<parent>
    <child>String 1</child>
    <child>String 2</child>
</parent>

Name the tags appropriately.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签