JAX WS:更改xmlns属性的位置 [英] JAX WS: Change location of xmlns attribute

查看:83
本文介绍了JAX WS:更改xmlns属性的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JAX WS正在生成以下内容(仅显示一个片段):

JAX WS is generating the following (only a snippet shown):

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:capMessageResponse xmlns:ns2="http://www.########.com" xmlns:ns3="test:one:two:1.2" xmlns:ns4="test:one:two:three:1.1">
         <ns3:alert>
            <ns3:identifier>1247275</ns3:identifier>

这是生成该方法的方法:

Here is the method that generates that:

@WebMethod(operationName = "capMessage", action = "urn:getCapMessages")
    @WebResult(name = "alert", targetNamespace="test:one:two:1.2")
    public List<AlertType> getCapMessage(String messageIds,String uniqueId,boolean skipHtmlStrip) throws CommsMessageException {
        try {

我们需要做的是从输出中删除capMessageResponse并将xmlns属性移到alert属性.

What we need want to do is remove the capMessageResponse from the output and have xmlns attribtues move to the alert attribute.

反正有这样做吗?

推荐答案

要实现所需的输出,请在服务实现bean上指定以下注释

To achieve the output you want, you specify the following annotation on your service implementation bean

    @SOAPBinding(style = Style.DOCUMENT,parameterStyle=SOAPBinding.ParameterStyle.BARE) 

仅当您的Web服务绑定为Document样式(这是默认设置,并且从外观上已经使用的方式)时,此注释才合法.

This annotation is only legal when your webservice binding is of the Document style (which is the default and what you're using already from the look of things).

对此选择要谨慎

  1. 您的消息有效负载不再使用操作名称进行包装,您已经知道/想要此操作

  1. Your message payloads are not wrapped with the operation names anymore, this you already know/want

直接由于以上1的结果,您将无法在同一Web服务上的其他操作中使用相同的实体/参数类型,因为调度程序将没有任何信息可以继续成功地调度该调度程序.消息

Directly as a result of 1. above you will not be able to use the same entity/argument type in another operation on the same web service as the dispatcher will not have any information to go on to successfully dispatch the message

此外,由于1(缺少相关信息),您的网络服务操作将无法接受多个参数

Also as a result of 1(lack of relevant info), your webservice operation will be unable to accept more than one parameter

这篇关于JAX WS:更改xmlns属性的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆