java.net.ConnectException: Connection timed out: connect in Eclipse - java

I am trying to consume below public web service using Eclipse.
http://www.webservicex.com/globalweather.asmx?wsdl
When I execute in the java client it gives the error;
java.net.ConnectException: Connection timed out: connect
Below is the simple client program;
public class ClientTest1
{
public static void main(String[] args)
{
GlobalWeatherSoapProxy obj1 = new GlobalWeatherSoapProxy();
try
{
System.out.println(obj1.getCitiesByCountry("Japan"));
}
catch(Exception e1)
{
System.out.println(+e1.getMessage());
}
}
}
However strangely this works fine when consumed through SOAP UI. Hence I assume this is something to do with Eclipse configuration.
Thank you in advance for any help.

Eclipse has nothing to do with it. Your code is executed by the JVM, even if your development environment is Eclipse. A connection time out means that your client is not able to connect with the endpoint.
You have auto-generated the client proxy in some way getting GlobalWeatherSoapProxy. This class will obtain the reference to endpoint by loading WSDL. Alternatively url can be provided by code. Review the content of that class to see how endpoint URL is loaded
You should see something like (check this full example)
URL url = new URL("http://localhost:9999/ws/hello?wsdl");
QName qname = new QName("http://ws.mkyong.com/", "HelloWorldImplService");
Service service = Service.create(url, qname);
HelloWorld hello = service.getPort(HelloWorld.class);

Related

cloudrail java desktop app

I'm trying to use cloudrail SDK in my java desktop app for testing ,
but I have problem with runing the sample code in cloudrailsite;
the following codes are main class:
public class DropboxWithCloudRail {
private static String REDIRECT_URL = "http://localhost:3000/";
InputStream inputStream = null;
public void loadDropbox() throws FileNotFoundException, ParseException {
CloudRail.setAppKey("*************");
Dropbox service = new Dropbox(new LocalReceiver(8082),
"*************",
"*************",
REDIRECT_URL,
"Dropbox"
);
service.createFolder(
"/myFolder1"
);
}
}
I set the Redirect URIs in dropbox console http://localhost:3000/
but when I run the project , I get this page:
This site can’t be reached
localhost refused to connect.
Did you mean http://localhost3000.org/?
Search Google for localhost 3000
ERR_CONNECTION_REFUSED
The issue seems to be that you configure your LocalRedirect receiver with the port 8082 which makes it wait for incoming redirects on http://localhost:8082. So this is the URL you have to use as a redirect uri for Dropbox and not http://localhost:3000.

Restlet error. unable to run the following server-side task httpserver.serverimpl

My smartphone collects GPS, Bluetooth log, then periodically send the data to server.
My server continuously receive the data by using Restlet.
However i encounter a error which i have never seen before and Google does not give any solution or hints. (my server has worked well for the past few days.)
Following message is errors i encountered.
Unable to run the following server-side task: sun-net.httpserver.ServerImpl$Exchange#81a5dc
Unable to run the following server-side task: sun-net.httpserver.ServerImpl$Exchange#~~~~~~
Unable to run the following server-side task: sun-net.httpserver.ServerImpl$Exchange#~~~~~~
Following is my code.
RestletServerMain.java
public void restServer(){
try{
Component component = new Component();
component.getServers().add(Protocol.HTTP, Integer.parseInt(Common.SERVER_PORT));
component.getDefaultHost().attach(new ServerApplication());
component.start();
}catch(Exception e){
e.printStackTrace();
}
}
ServerApplication.java
public class ServerApplication extends Application {
public Restlet createInboundRoot() {
Router router = new Router(getContext());
router.attach("/dataprocessing1", xxx.class);
router.attach("/dataprocessing2", yyy.class);
return router;
}
It could be interesting to try the jetty extension (org.restlet.extends.jetty) of Restlet (instead of the default one).
Just add the corresponding jar file in your classpath and Jetty will be used as underlying server for your application.
Hope it will fix your issue.
Thierry

How to execute Glassfish Web Service in Java Client

i would like to execute a Web Service in a Java Client. I created a "Web Service Client" in a "Java Application" with Netbeans (with "WSDL URL"). So far so good.
My Problem is now i don't know how to call my Service. I did a rightclick in my Code and clicked "Insert Code..." and than "Call Web Service Operation...".
Netbeans generate this code:
stormgs.GetLdevInfoService service = new stormgs.GetLdevInfoService();
QName portQName = new QName("http://StormGS/", "GetLdevInfoPort");
String req = "<getStorageInfo xmlns=\"http://StormGS/\"></getStorageInfo>";
try { // Call Web Service Operation
Dispatch<Source> sourceDispatch;
sourceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD);
Source result = sourceDispatch.invoke(new StreamSource(new StringReader(req)));
} catch (Exception ex) {
System.out.println("damn " + ex);
}
But im not sure if this work. Furthermore in the last line of the try-Block it throws me this Exception:
com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect
Can anyone help me. I only want to call my Web Service in this Client. Thanks!

Hosting a java made webservice

So I have been working on a web service which communicates between the client and server. It fully works on my computer and am able to send requests from client to server while not in the same package.
I am hosting my service like:
public class WebServiceServer {
public static void main(String[] args) {
String bindingURI = "http://localhost:4040/absolute/uploadService";
FileReceive service = new FileReceiveImpl();
Endpoint.publish(bindingURI, service);
System.out.println("Server started at: " + bindingURI);
}
}
And my client connects to my service like:
public static void main(String args[]) throws Exception {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(FileReceive.class);
factory.setAddress
("http://localhost:4040/absolute/uploadService");
FileReceive client =(FileReceive) factory.create();
From this point I would like to make the web-service public(able to connect from outside of the local-host). I installed ruby and ruby gems only to find out the local-tunnel is no longer available. I have then moved to using ngrok which forwarded a URL for me, but I cannot get any post requests to go through to it(as if it was my web-service) only get methods as I type the URL into my web-browser. Is anyone aware of any easier to use hosting services so that someone (outside of local-host) can post a file to my web-service? Thanks.

Connecting Remotely with Java Web Services

Can someone please tell me what I'm doing wrong?
I'm trying to put together a quick web service test just to see if I can get it to work for now.
The problem I'm having is that, as shown below, it does not work, but if I change the URL and replace "myWebsite.com" with "localhost" it works. So, I know the server side is working (I've still checked and double checked it though). But I'll need this to work through remote clients, and I just cannot get it to work.
Any help would be greatly appreciated.
package stickman.Server;
import java.net.*;
import javax.xml.namespace.*;
import javax.xml.ws.*;
import stickman.Combined.*;
public class TestApp {
public static void main(String[] args) throws Exception {
// --------------------------------------------
// changing "myWebite.com" to "localhost" works
URL url = new URL(
"http://myWebsite.com:32768/home/rhyan/workspace/Stickman/bin/stickman/Server");
// --------------------------------------------
QName qname = new QName("http://Server.stickman/","StickmanServerService");
Service service = Service.create(url, qname);
StickmanServerInterface ssi = service.getPort(StickmanServerInterface.class);
Account a = ssi.getAccount("This is a test");
System.out.println(a.getUserId());
}
}
Edit: here's the error tracking...
Exception in thread "main" com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException: 2 counts of InaccessibleWSDLException.
java.net.ConnectException: Connection refused
java.net.ConnectException: Connection refused
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:161)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:133)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:254)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:217)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:165)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:93)
at javax.xml.ws.Service.<init>(Service.java:76)
at javax.xml.ws.Service.create(Service.java:700)
at stickman.Server.ServerTestApp.main(ServerTestApp.java:17)
Could be a DNS problem? What IP address do you resolve myWebsite.com to?
Your exception indicates that the wsdl for the service is not accessible - not the service itself. Can you confirm that the wsdl for the service is available at this location - http://myWebsite.com:32768/home/rhyan/workspace/Stickman/bin/stickman/Server, and the url in the wsdl points to a proper working endpoint.
It took 8 days of reading a plethora of stuff online before I finally found the answer to my problem through a random google search I came up with: Publishing a WS with Jax-WS Endpoint
"localhost" should be 0.0.0.0, and I totally should have known this.
Thanks to the people who tried to help.

Categories

Resources