Java XML请求/响应中的框架根元素

Java XML请求/响应中的框架根元素,java,web-services,jax-ws,Java,Web Services,Jax Ws,我使用自顶向下的方法从WSDL生成代码。SOAPWebService中的输入/输出XML结构生成如下 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.test.com/"> <soapenv:Header/> <soapenv:Body> <web:operationNa

我使用自顶向下的方法从WSDL生成代码。SOAPWebService中的输入/输出XML结构生成如下

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.test.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:operationName>
           <RootElement> .......
               -----
           </RootElement>
     </web:operationName>
   </soapenv:Body>
</soapenv:Envelope>

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.test.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:operationNameResponse>
           <RootElement> .......
               -----
           </RootElement>
     </web:operationNameResponse>
   </soapenv:Body>
</soapenv:Envelope>

希望避免
元素出现在我的根元素上方的主体中。如何删除它?

您可以通过在注释上设置以下属性来实现该输出

  • 样式
    文档

  • 使用
    文字

  • parameterStyle
    BARE
    。这里的默认值是
    WRAPPED
    ,这正是您不想要的

@WebService
public interface classname
{
@WebMethod
@WebResult(name = "RootElement")
public abstract String operationName(@WebParam(name = "RootElement") String data)
}