WSDL中的参数名称具有重要名称 [英] Parameter Names in WSDL with significant name

查看:147
本文介绍了WSDL中的参数名称具有重要名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JAXWS RI在Java中创建WebService。
自动部署应用程序WAR时创建WSDL文件。
问题是我希望WSDL文件中的参数(每个操作都收到)具有重要名称,但它们显示为arg0,arg1,arg2 ...
有没有办法定义这些参数的名称并不使用默认名称?

I am creating a WebService in Java using JAXWS RI. The WSDL file is created when deploying the application WAR automatically. The problem is that I want the arguments (that each operation recieves) in the WSDL file to have significant names, but they appear as arg0, arg1, arg2 ... Is there a way to define the names for this parameters and don't use the default names?

我已实现以下内容:

WebService接口

The WebService Interface

@WebService
@SOAPBinding(style = Style.RPC)
public interface WS2 {
    @WebMethod String confirmaXML(String lrt_id);
}

WebService接口实施

The WebService Interface Implementation

@WebService(endpointInterface = "vital.tde.ws2.WS2")
public class WS2Imp implements WS2{
    public String confirmaXML(String lrt_id) {
        String respuesta = null;
        //CODE
        return respuesta;
    }

sun-jaxws.xml

sun-jaxws.xml

<?xml version="1.0" encoding="UTF-8"?>
<endpoints
    xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
    version="2.0">
    <endpoint name="WS2" implementation="vital.tde.ws2.WS2Imp" url-pattern="/WS2" />
</endpoints>

web.xml

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>WS2</display-name>
  <listener>
    <listener-class>
                com.sun.xml.ws.transport.http.servlet.WSServletContextListener
        </listener-class>
  </listener>
  <servlet>
    <servlet-name>WS2</servlet-name>
    <servlet-class>
            com.sun.xml.ws.transport.http.servlet.WSServlet
        </servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>WS2</servlet-name>
    <url-pattern>/WS2</url-pattern>
  </servlet-mapping>
  <session-config>
    <session-timeout>120</session-timeout>
  </session-config>
</web-app>


推荐答案

如果您从Web服务生成WSDL类,您可以添加 WebParam 对方法参数的注释,以强制在WSDL中进行命名。例如:

If you're generating your WSDL from your web service class, you may add WebParam annotations to the parameters of your methods to enforce naming in the WSDL. For example:

@WebService
public class FooService
{
    @WebMethod(operationName = "barMethod")
    public void bar (@WebParam(name = "bazArg") int baz)
    {
        ...
    }
}

上面的代码片段将JAX-WS配置为在WSDL中使用名称bazArg作为方法的参数名称。

The above snippet configures JAX-WS to use the name "bazArg" for the method's parameter name in the WSDL.

这篇关于WSDL中的参数名称具有重要名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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