views:

80

answers:

1

Hello Folks,

I build a minimal Webservice and published it by 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 recieve 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 192.... but not on localhost.

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

+1  A: 

Could you try publishing it on 0.0.0.0?

ivy
This works. localhost, 0.0.0.0 and 192.168.0.133 gets me the wsdl. But why doesn't it, while publishing on localhost or the other ip.
daniel
Happy to hear it works. localhost is ip 127.0.0.1 , and Endpoint.publish (obviously) only binds to the provided address. With 0.0.0.0 you tell it to 'listen' to incoming connections to any ip-address (associated with your computer).It can be a handy feature to only bind to a specific ip-address, e.g. if you want your service to be only available to a certain subnet...
ivy