0

I am trying to put a web service, made in Eclipse, on my WAMP server. I get the generated WSDL file in Eclipse and I put the WSDL file in the www folder on my WAMP server. I need to access this web service remotely, but when I create a client from a remote computer(after importing the generated files from the WSDL on my website) it says connection refused when I try to run it.

Here is the error code:

Exception in thread "main" AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: java.net.ConnectException: Connection refused
 faultActor: 
 faultNode: 
 faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:153)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:120)
    at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
    at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at DefaultNamespace.WebserviceSoapBindingStub.echo(WebserviceSoapBindingStub.java:106)
    at DefaultNamespace.message.main(message.java:18)

    {http://xml.apache.org/axis/}hostname:Shadow.local

java.net.ConnectException: Connection refused
    at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at DefaultNamespace.WebserviceSoapBindingStub.echo(WebserviceSoapBindingStub.java:106)
    at DefaultNamespace.message.main(message.java:18)
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:153)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:120)
    at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
    at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
    ... 11 more

It works in Eclipse using Apache Tomcat 8.0 (my WAMP server is running Apache 2.4.9), but I don't know why I am getting a connection refused. I have opened port 80 and port 8080

Also here is the client I made: *Note: Echo is just supposed to return what you put in it.

package DefaultNamespace;
import java.util.*;
import java.io.*;

import javax.xml.rpc.ServiceException;
public class message {
    public static void main(String[] args) throws IOException
    {
        Scanner in = new Scanner(System.in);

        System.out.println("Enter a word: ");
        String a = in.next();

        WebserviceServiceLocator locator = new WebserviceServiceLocator();
        WebserviceSoapBindingStub stub;
        try {
            stub = (WebserviceSoapBindingStub)locator.getwebservice();
            System.out.println(stub.echo(a));
        } catch (ServiceException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.out.println(e.getMessage());
        }
    }
}

If I can't access my web service remotely via my WAMP server then how can I? Thanks

ghost1349
  • 83
  • 1
  • 10

1 Answers1

0

WAMPServer is configured to be a developer tool, so for the security of beginners, and those who think they know more than they actually do, Apache is configured to accept connections only from the PC running WAMPSever(Apache) i.e. localhost

If you want to allow access from anywhere else you will have to change httpd.conf to allow access from elsewhere.

There is a menu option on the wampmanager menus called Put Online, this will make the change to httpd.conf for you, changing

Require local

to

Require all granted

And allow access from the internet, assuming you have correctly port forwarded your router.

However this is dangerous on a vanilla install of WAMPServer as it will allow access to EVERYTHING including phpMyAdmin which basically gives away the crown jewels.

A safer solution would be to manually change the httpd.conf file and allow just the ip addresses that you want to allow like so :-

Find the section on httpd.conf starting <Directory "c:/wamp/www/">

Require local
Require ip w.x.y.z

Or maybe even better in your case would be to specify a host from which connections are allowed.

Require local
Require host example.org

Of course a better solution would be to create a Virtual Host for your site, this way you leave general access limited to localhost but allow access to this testing site to specific ip's or domains. See this post for help creating Virtual Hosts

Community
  • 1
  • 1
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149