Java – parameter names in WSDL with important names

I am using jaxws RI to create a web service in Java

I have implemented the following:

WebService interface

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

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

<?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. In 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>

Solution

If you want to generate WSDL from a web service class, you can add the webparam annotation in the WSP (see here) to the parameters of the method to enforce naming For example:

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

The above code snippet configures Jax - ws to use the parameter name "bazarg" of the method in WSDL

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>