java 无法访问 WSDL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37733041/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 02:44:26  来源:igfitidea点击:

Failed to access the WSDL

javawsdl

提问by Corvo Attano

Hello I am trying setting up a simple WSDL program in Java but I get the following error, any advices? I am fairly new at this, and this program is my first one of sorts.

您好,我正在尝试用 Java 设置一个简单的 WSDL 程序,但出现以下错误,有什么建议吗?我对此很陌生,这个程序是我的第一个程序。

Thank you,

谢谢,

package de.vs.webServices.clientSide;

import java.net.URL;
import java.util.Scanner;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import de.vs.webServices.serverSide.ZeichenketteInt;

public class ZeichenketteClient {

public static void main(String[] args) throws Exception {

URL url = new URL("http://localhost:9999/vs/Zeichenkette?wsdl");

QName qname = new       QName("http://serverSide.webServices.vs.de/","ZeichenketteImplService");

Service service = Service.create(url, qname);

ZeichenketteInt zeichenketteInt = service.getPort(ZeichenketteInt.class);

Scanner sc = new Scanner(System.in);
int nr=0;
do {
    System.out.println("Waehlen Sie die Nummer eines Befehls oder 0 um das Programm zu beenden: ");
    System.out.println("1. Zeichen Doppeln");
    System.out.println("2. Zeichenkette Verdoppeln");
    System.out.println("3. ZeichenketteSpiegeln");
    System.out.println("4. ZeichenketteLange");
    nr = sc.nextInt();
    String zeichenkette = null;
    switch (nr) {
    case 1:
        System.out
                .println("Schreiben Sie die gewunschte Zeichenkette: ");
        zeichenkette = sc.next();
        System.out.println("Ergebnis: "
                + zeichenketteInt.zeichenDoppeln(zeichenkette));
        break;
    case 2:
        System.out
                .println("Schreiben Sie die gewunschte Zeichenkette: ");
        zeichenkette = sc.next();
        System.out.println("Ergebnis: "
                + zeichenketteInt.zeichenKetteVerdoppeln(zeichenkette));

        break;
    case 3:
        System.out
                .println("Schreiben Sie die gewunschte Zeichenkette: ");
        zeichenkette = sc.next();
        System.out.println("Ergebnis: "
                + zeichenketteInt.zeichenKetteSpiegeln(zeichenkette));
        break;
    case 4:
        System.out
                .println("Schreiben Sie die gewunschte Zeichenkette: ");
        zeichenkette = sc.next();
        System.out.println("Ergebnis: "
                + zeichenketteInt.zeichenKetteLange(zeichenkette));
        break;
    }
} while (nr!=0);
sc.close();

}}

}}

This is the error that I get:

这是我得到的错误:

        Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://localhost:9999/vs/Zeichenkette?wsdl. It failed with: 
    Connection refused: connect.
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(Unknown Source)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(Unknown Source)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
    at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(Unknown Source)
    at javax.xml.ws.Service.<init>(Unknown Source)
    at javax.xml.ws.Service.create(Unknown Source)
    at de.vs.webServices.clientSide.ZeichenketteClient.main(ZeichenketteClient.java:19)
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.<init>(Unknown Source)
    at sun.net.www.http.HttpClient.New(Unknown Source)
    at sun.net.www.http.HttpClient.New(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.URL.openStream(Unknown Source)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.createReader(Unknown Source)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(Unknown Source)
    ... 12 more

回答by The_GM

The part of the error that says: "refused: connect" is telling you that the server (localhost in this case) rejected your connection request.

错误部分说:“拒绝:连接”是告诉您服务器(在本例中为 localhost)拒绝了您的连接请求。

I would check that the URI: http://localhost:9999/vs/Zeichenkette?wsdlactually returns a WSDL document. Just open it in a web browser and see what you get back. If the browser can't open it, Java can't either. Once the browser will open it, Java should have no problem with it (though it occasionally happens that the browser reads it fine and permissions in Java stop you, this doesn't appear to be one of those cases).

我会检查 URI:http://localhost:9999/vs/Zeichenkette?wsdl实际上返回了一个 WSDL 文档。只需在网络浏览器中打开它,看看你会得到什么。如果浏览器不能打开它,Java 也不能。一旦浏览器打开它,Java 应该没有问题(尽管偶尔会发生浏览器读取它的情况并且 Java 中的权限阻止你,这似乎不是这些情况之一)。

Then I suggest looking to make certain that the server port is open (IPTables, AV, things like that can block it). Note that this is not likely your problem, since the error is reading the WSDL. I'm looking ahead to after the WSDL loads.

然后我建议确保服务器端口是打开的(IPTables、AV 之类的东西可以阻止它)。请注意,这可能不是您的问题,因为错误是读取 WSDL。我期待着加载 WSDL 之后。