为JAX-WS应用什么自定义来将返回对象展开到列表



我试图找到是否有一种方法来定制,例如CSID2ExtRefs操作ChemSpider WebService传递字符串列表作为参数之一,并返回对象列表:

<!-- Request element: -->
<s:element name="CSID2ExtRefs">
  <s:complexType>
    <s:sequence>
      <s:element minOccurs="1" maxOccurs="1" name="CSID" type="s:int"/>
      <s:element minOccurs="0" maxOccurs="1" name="datasources" type="tns:ArrayOfString"/>
      <s:element minOccurs="0" maxOccurs="1" name="token" type="s:string"/>
    </s:sequence>
  </s:complexType>
</s:element>
<!-- Response element: -->
<s:element name="CSID2ExtRefsResponse">
  <s:complexType>
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="CSID2ExtRefsResult" type="tns:ArrayOfExtRef"/>
    </s:sequence>
  </s:complexType>
</s:element>
<s:complexType name="ArrayOfExtRef">
  <s:sequence>
    <s:element minOccurs="0" maxOccurs="unbounded" name="ExtRef" type="tns:ExtRef"/>
  </s:sequence>
</s:complexType>
<s:complexType name="ArrayOfString">
  <s:sequence>
    <s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string"/>
  </s:sequence>
</s:complexType>

wsimport界面法生成的(与jaxws:enableWrapperStyle = true)为:

@WebMethod(operationName = "CSID2ExtRefs", action = "http://www.chemspider.com/CSID2ExtRefs")
@WebResult(name = "CSID2ExtRefsResult", targetNamespace = "http://www.chemspider.com/")
@RequestWrapper(localName = "CSID2ExtRefs", targetNamespace = "http://www.chemspider.com/", className = "chemspider.core.CSID2ExtRefsRequest")
@ResponseWrapper(localName = "CSID2ExtRefsResponse", targetNamespace = "http://www.chemspider.com/", className = "chemspider.core.CSID2ExtRefsResponse")
public ArrayOfExtRef csid2ExtRefs(
    @WebParam(name = "CSID", targetNamespace = "http://www.chemspider.com/")
    int csid,
    @WebParam(name = "datasources", targetNamespace = "http://www.chemspider.com/")
    ArrayOfString datasources,
    @WebParam(name = "token", targetNamespace = "http://www.chemspider.com/")
    String token);

但我想有ArrayOfExtRefArrayOfString打开并转向列表,例如获得以下内容:

public List<ExtRef> csid2ExtRefs(
    @WebParam(...)
    int csid,
    @WebParam(...)
    List<String> datasources,
    @WebParam(...)
    String token);

如果我手动进行此更改,则JAX-WS可以正常工作。我想知道,是否有任何方法来编写适当的定制?

首先,所有web服务标准还不是100%可移植的。替换

<s:element minOccurs="0" maxOccurs="1" name="datasources" type="tns:ArrayOfString"/>

<s:element name="datasources" type="xs:string" form="qualified" minOccurs="0" maxOccurs="unbounded" />

也可代替

<s:element minOccurs="0" maxOccurs="1" name="CSID2ExtRefsResult" type="tns:ArrayOfExtRef"/>

<s:element minOccurs="0" maxOccurs="unbounded" name="CSID2ExtRefsResult" type="tns:ExtRef"/>

您也可以删除复杂类型,如"ArrayOfString",ArrayOfExtRef.

最新更新