use*_*509 13 java wsdl web-services jax-ws
我正在使用JAXWS RI在Java中创建WebService.在自动部署应用程序WAR时会创建WSDL文件.问题是我希望WSDL文件中的参数(每个操作都收到)具有重要的名称,但是它们显示为arg0,arg1,arg2 ...有没有办法为这些参数定义名称而不是使用默认名称?
我已经实现了以下内容:
WebService接口
@WebService
@SOAPBinding(style = Style.RPC)
public interface WS2 {
@WebMethod String confirmaXML(String lrt_id);
}
Run Code Online (Sandbox Code Playgroud)
WebService接口实现
@WebService(endpointInterface = "vital.tde.ws2.WS2")
public class WS2Imp implements WS2{
public String confirmaXML(String lrt_id) {
String respuesta = null;
//CODE
return respuesta;
}
Run Code Online (Sandbox Code Playgroud)
太阳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>
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
Mac*_*Mac 25
如果要从Web服务类生成WSDL,则可以WebParam向方法的参数添加注释,以在WSDL中强制命名.例如:
@WebService
public class FooService
{
@WebMethod(operationName = "barMethod")
public void bar (@WebParam(name = "bazArg") int baz)
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码片段将JAX-WS配置为在WSDL中使用名称"bazArg"作为方法的参数名称.
| 归档时间: |
|
| 查看次数: |
12226 次 |
| 最近记录: |