When I use an "Endpoint" class to publish a Web Service, where is the WSDL created?

Asked

Viewed 1,199 times

2

For example, I have 3 classes in my Web Service:

1 - A SEI (the web service interface):

package calc;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

@WebService
@SOAPBinding(style = Style.RPC)
public interface CalculatorServer {
    @WebMethod float sum(float num1, float num2);
    @WebMethod float subtraction(float num1, float num2);
    @WebMethod float multiplication(float num1, float num2);
    @WebMethod float division(float num1, float num2);
}

2 - A SIB (the implementation of the Interface):

package calc;

import java.util.Date;
import javax.jws.WebService;

@WebService(endpointInterface = "calc.CalculatorServer")
public class CalculatorServerImpl implements CalculadoraServer {

    public float sum(float num1, float num2) {
        return num1 + num2;
    }

    public float subtraction(float num1, float num2) {
        return num1 - num2;
    }

...

}

3 - And the class responsible for publishing it:

package calc;

import javax.xml.ws.Endpoint;

public class CalculadoraServerPublisher {

    public static void main(String[] args)
    {
        Endpoint.publish("http://127.0.0.1:9876/calc",
        new CalculadoraServerImpl());
    }
}

If I run third class and access the address:

http://127.0.0.1:9876/calc?wsdl

I will see the WSDL of my Web Service. Hence the question: if I can access it, it is physically allocated somewhere on my computer, but... WHERE? I tried to use all the Windows search tools I know (I use Windows 8.1) and none of them could find it. Where is he, after all?

1 answer

0


Hence the question: if I can access it, it is physically located somewhere on my computer, but... WHERE?

It is not true that if you are accessing some resource it necessarily needs to be physical and be somewhere on the computer. The case presented by you is one of these scenarios, since the WSDL is storing in memory (not the WSDL exactly, but what forms it).

With JAX-RS, if we do not inform the WSDL location it is generated automatically. In the JAX-WS specification (recital 2.2), we have the following in 5.2.2 Publicação:

The WSDL Contract for an endpoint is created dynamically based on the Annotations on the implementor class, the Binding in use and the set of Metadata Documents specified on the endpoint (see 5.2.4)

That is, the WSDL is created dynamically and the metadata of endpoints is created based on annotations. However in the specification there is nothing that speaks HOW these artifacts must be stored.

Each implementation of the specification stores the WSDL in a way, so to know details of WHERE is stored, it is necessary to see how each implementation performs this task, but since it already has the metadata it is common that it is in memory in some object and is serialized whenever the URL is terminated in ?wsdl or ?WSDL is called.

You can look in detail at the JAX-WS specification available at https://jax-ws.java.net/, the topics 5.2.4 and 5.2.5 have relevant information, in addition to documentation of JAX-WS implementations that meet these points of the specification, such as looking at the classes of the packages com.sun.xml.internal.ws.transport and com.sun.xml.internal.ws.wsdl, from JDK, to see how references are stored for serialization.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.