Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web services 更改邮件名称_Web Services_Wsdl_Jax Ws - Fatal编程技术网

Web services 更改邮件名称

Web services 更改邮件名称,web-services,wsdl,jax-ws,Web Services,Wsdl,Jax Ws,这是我的WSDL的一部分。我使用的是代码优先的方法 <portType name="MyWebService"> <operation name="echoString"/> <input message="echoString"/> <output message="echoStringResponse"/> </operation> </portType>

这是我的WSDL的一部分。我使用的是代码优先的方法

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

我应该添加或更改什么注释才能更改此值

<input message="echoString"/>

读作

<input message="echoStringRequest"/>


谢谢大家。

我自己也很惊讶,但在尝试了一段时间后,我研究了规范,似乎您无法在jax ws中真正做到这一点(除非以非标准方式,具体取决于实现)。以下是政府对这个问题的看法。请参阅Java到WSDL 1.1映射,第3.5节,第32页:

wsdl:message元素的name属性的值不正确 重要,但按照惯例,它通常等于 输入消息对应的操作名称和操作名称 与输出消息的“响应”连接。断层命名 第3.7节介绍了信息

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

@WebMethod(operationName=“echoStringRequest”)
公共字符串echoString(字符串echoStringRequest){
返回请求;
}
这将生成以下
portType

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


你是否对这个版本更满意取决于你自己。

我最近也遇到过这个问题,并且多次偶然发现这个问题。在我们的应用程序中,我们有一个JAX-WSservlet,它必须使用…请求和…响应的格式

经过几天的搜索,我找到了解决办法

假设echoStringRequest有一个字符串属性,应该在响应中回显

class EchoMessage {
    private String message;

    //add getter and setter
}
首先将此注释添加到web服务类:

@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
然后像这样注释您的web服务方法:

@WebMethod
@WebResult(name = "echoStringResponse")
public EchoMessage echoString (@WebParam(name = "echoStringRequest") EchoMessage inputMessage) {
    ...
}
<echoString>
    <echoStringRequest>
        ...
    </echoStringRequest>
</echoString>
如果没有parameterStyle BARE注释,JAX-WS将自动生成如下消息:

@WebMethod
@WebResult(name = "echoStringResponse")
public EchoMessage echoString (@WebParam(name = "echoStringRequest") EchoMessage inputMessage) {
    ...
}
<echoString>
    <echoStringRequest>
        ...
    </echoStringRequest>
</echoString>

...
通过注释,外部元素不再存在

需要@WebParam和@ReturnType注释来确定SOAP请求和响应主体中根元素的名称