santiagollo
santiagollo

Reputation: 31

Consuming web service from a remote computer

I have a desktop application built with jdk 6 which publishes web services to be consumed by a web application. So far I've had no problem while both applications are running in the same physical computer, i can access the wsdl without any problem and the web application works with the desktop application just fine. The thing is I cannot access to the services from a remote computer in the same network. The two PCs are connected and can interact. If I run both applications in PC1, from PC2 I can use the webapp through

http://PC1:8080

I am currently publishing like this:

public Publicador(){
 servicios= new Servicios();
Endpoint endpoint = Endpoint.publish("http://PC1:8686/servicios", servicios);
}

where PC1 is the name of the pc. From PC1, i can see the generated wsdl from the following address, and it's the one I used for the wsimport command:

http://PC1:8686/servicios?wsdl

But I cannnot from PC2.

Any ideas why it is not visible from outside PC1?

Upvotes: 1

Views: 2547

Answers (1)

santiagollo
santiagollo

Reputation: 31

Incredible as it may seem, I found the simplest of answers... Instead of publishing as

Endpoint endpoint = Endpoint.publish("http://PC1:8686/servicios", servicios);

I published as

Endpoint endpoint = Endpoint.publish("http://0.0.0.0:8686/servicios", servicios);

and that solved it...

Another solution was to get the address to publish from a file, that worked too. I don't know why it didn't hardcoded... I ended up doing it like this:

Properties prop = new Properties();
InputStream is = null;
String currenDir = System.getProperty("user.dir");
String nombreArchivo = currenDir + File.separator + "ubicacion.PROPERTIES";
try {
is=new FileInputStream(nombreArchivo);
prop.load(is);
} catch(IOException ioe) {}

String pc = prop.getProperty("ServiciosWeb");      
Endpoint endpoint = Endpoint.publish( pc, servicios);
}

Upvotes: 2

Related Questions