我不确定可能是什么问题。我在 JDK 6 中使用 JAX-WS RI 2.1.6(这个运行时是 JDK 的一部分)并且运行顺利。
枚举:
public enum Result {
FAILURE;
}
响应包装器:
public class RequestStatus {
private Result result;
public RequestStatus() {
}
public RequestStatus(Result result) {
this.result = result;
}
public Result getResult() {
return result;
}
public void setResult(Result result) {
this.result = result;
}
}
请求包装器:
public lass ReferenceDataSetList {
private List<String> list;
public List<String> getList() {
return list;
}
public void setList(List<String> list) {
this.list = list;
}
}
和 SEI 类:
package test;
import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
@WebService
public class TestService {
@WebMethod
public RequestStatus setReferenceData(ReferenceDataSetList refData) {
return new RequestStatus(Result.FAILURE);
}
public static void main(String[] args) {
Endpoint.publish("http://localhost:8084/service", new TestService());
}
}
控制台输出是:
28/02/2013 10:34:43 AM com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass
INFO: Dynamically creating request wrapper Class test.jaxws.SetReferenceData
28/02/2013 10:34:43 AM com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
INFO: Dynamically creating response wrapper bean Class test.jaxws.SetReferenceDataResponse
我可以在http://localhost:8084/service?wsdl
. 列表和枚举(片段)的架构是:
<xs:complexType name="setReferenceData">
<xs:sequence>
<xs:element name="arg0" type="tns:referenceDataSetList"
minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="referenceDataSetList">
<xs:sequence>
<xs:element name="list" type="xs:string" nillable="true" minOccurs="0"
maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="requestStatus">
<xs:sequence>
<xs:element name="result" type="tns:result" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="result">
<xs:restriction base="xs:string">
<xs:enumeration value="FAILURE"></xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:schema>