Web服务连接被拒绝

时间:2014-12-07 02:14:59

标签: java eclipse web-services

我正在尝试连接到我的网络服务,麻烦的是我的连接被拒绝了。我在运行Web服务的服务器上运行WAMP,我在eclipse上运行Apache Tomcat8。这是堆栈跟踪:

Dec 06, 2014 8:08:39 PM org.apache.axis.utils.JavaUtils isAttachmentSupported
WARNING: Unable to find required classes (javax.activation.DataHandler and     javax.mail.internet.MimeMultipart). Attachment support is disabled.
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

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

以下是客户:

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();
    }
   }
}

Echo只返回你输入的内容。

1 个答案:

答案 0 :(得分:0)

当我使用在glassfish上部署的Web服务时,我遇到了类似的错误,这是因为我以前杀死了glassfish进程,因此服务器停止了运行。这就是为什么无法在客户端和Web服务之间建立连接的原因。检查您的Tomcat服务器是否仍在运行。