Publishing a WS with Jax-WS Endpoint

橙三吉。 提交于 2019-11-26 20:12:50

问题


I built a minimal web service and published it using javax.xml.ws.Endpoint. If I try to get the WSDL at http://localhost:1234/AddService?wsdl it works fine.

Trying to recieve it at http://192.168.0.133:1234/AddService?wsdl, I don't receive anything. This address is the same as localhost.

Is there a posibiility to publish a webservice without providing the address?

package test;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;

@WebService
public class AddService {

    @WebMethod
    public int add(int a, int b){
        return a+b;
    }

    public static void main(String[] args ){
        Endpoint.publish("http://localhost:1234/AddService", new AddService());
    }
}

Changing the code to

Endpoint.publish("http://192.168.0.133:1234/AddService", new AddService());

gets me the wsdl on the IP address but not on localhost.

Isn't there a posibility to just define the port?


回答1:


Could you try publishing it on 0.0.0.0?




回答2:


Here is my code:

Endpoint.publish("http://localhost:8080", new ServiceController());

It says The address's path should start with /



来源:https://stackoverflow.com/questions/3680600/publishing-a-ws-with-jax-ws-endpoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!