Java 如何使用Jax-WS使字段成为必需的

Java 如何使用Jax-WS使字段成为必需的,java,web-services,soap,jax-ws,Java,Web Services,Soap,Jax Ws,我需要根据需要设置我的WebServices字段。我使用以下依赖项来构建Web服务:编译组:“com.sun.xml.ws”,名称:“jaxws-rt”,版本:“3.0.0-M4” 我的代码是这样的: Web服务接口: @WebService public interface TestService { @WebMethod Integer test(Integer age) throws Exception; } 服务实现 @WebService public class T

我需要根据需要设置我的WebServices字段。我使用以下依赖项来构建Web服务:
编译组:“com.sun.xml.ws”,名称:“jaxws-rt”,版本:“3.0.0-M4”

我的代码是这样的:

  • Web服务接口:

    @WebService
    public interface TestService {
       @WebMethod
       Integer test(Integer age) throws Exception; 
    }
    
  • 服务实现

    @WebService
    public class TestServiceImpl implements TestService {
    @WebMethod
    public Integer test(@WebParam(name = "test")  @XmlElement(required = true) Integer age) {
       return age;
    }
    
  • 这就是我发布端点的方式

    Endpoint.publish("http://0.0.0.0:8092/services", new TestServiceImpl());
    
  • 因此,使用@XmlElement(required=true)应该将所选字段设置为“required”,但实际上并非如此。当该字段未在请求中使用时,不会发生任何事情

    它应该将xsd模式中的“minOccurs”参数更改为1,但无论我做什么,它都保持为0

    <xs:sequence>
    <xs:element name="arg0" type="xs:int" minOccurs="0"/>
    </xs:sequence>
    
    
    
    我如何使任何字段成为必填字段