File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Can't connect to my web service remotely (very basic example) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Can Watch "Can New topic

Can't connect to my web service remotely (very basic example)

Will Farquharson

Joined: Dec 02, 2008
Posts: 20


I've been using Netbeans 6 to get to grips with Java Web Services, and I've developed them exclusively using this IDE including a client program to consume them.

Everything has been working fine when running my server and client on the same machine, but I've recently been trying to get my client to talk to the web service when it's deployed somewhere remote and I must be missing a huge step somewhere because I simply can't get this to work.

I can view the WSDL file through a web browser fine, so I know the correct port is open and the web services should be there - but when my client tries to call the very first method on the web service, it says "Connection Refused" - I've made sure everything that used to previously reference "localhost" now references the external IP address in all the classes on the client, but I must be missing something else, or there is a configuration issue.

It may be worth noting that this link:
http://localhost:8080/Evaluator/EvaluatorService?Tester fine on the server machine, but if I try to call it remotely by replacing "localhost" with an IP address, I get displayed on the page...

"Exceptions details : null
java.lang.NullPointerException at
at com.sun.enterprise.webservice.monitoring.WebServiceTesterServlet.initializePort( at..."

...which seems a bit meaningless :-( I don't understand why this wouldn't return the same page as it does on the local machine?

I realise this is probably a very basic question, I still have absolutely heaps to learn about Web Services but I hoped to have this simple system working fairly quickly as a starting point. I've tried looking up some resources, but I either find examples too basic, or far too complicated for me to understand yet. If anyone could give me some pointers as to what to check I would be very grateful...

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

I notice that something is trying to use a File object. That doesn't seem like a reasonable thing for a web service to do.

And given that you say your code works when the client and server are the same machine but not when they aren't, it very much makes me suspect that it's your code which is trying to access a file. Naturally code on the server won't be able to access files on the client machine -- at least, not via a File object.
Will Farquharson

Joined: Dec 02, 2008
Posts: 20

That link is just to a Web Service testing page that usually appears if you click "Test Web Service" from the right click menu in Netbeans - I'm not sure what it does behind the scenes with files etc, but it usually just displays a list of all the methods you have and lets you invoke them to see if they are work. I thought the fact that this page didn't work remotely might be a good indicator as to why my client can't consume the web service either.... I could be wrong though.
I agree. Here's the link:
subject: Can't connect to my web service remotely (very basic example)
jQuery in Action, 3rd edition