web-services – 更改消息名称

这是我的WSDL的一部分.我正在使用代码第一种方法.

<portType name="MyWebService">
     <operation name="echoString"/>
         <input message="echoString"/>
         <output message="echoStringResponse"/>
     </operation>
 </portType>

我应该添加或更改什么注释以便更改此注释

<input message="echoString"/>

读为

<input message="echoStringRequest"/>

谢谢大家.

最佳答案 我自己很惊讶,但经过一段时间的努力后,我查看了规范,看起来你不能在jax-ws中真正做到这一点(除非以非标准的方式,取决于实现).这是
jax-ws 2.0 specification在这个问题上所说的内容.请参阅Java到WSDL 1.1映射,第3.5节,第32页:

The value of a wsdl:message element’s name attribute is not
significant but by convention it is normally equal to the
corresponding operation name for input messages and the operation name
concatenated with “Response” for output messages. Naming of fault
messages is described in section section 3.7.

因此,我想到的唯一选择是重命名您的操作,例如通过更改或添加@WebMethod注释.这是一个例子:

@WebMethod(operationName = "echoStringRequest")
public String echoString(String echoStringRequest) {
    return echoStringRequest;
}

这将生成以下portType:

<portType name="MyWebService">
   <operation name="echoStringRequest">
      <input message="tns:echoStringRequest"></input>
      <output message="tns:echoStringRequestResponse"></output>
   </operation>
</portType>

您是否对此版本感到满意的决定取决于您.

点赞