java WSDL 定位器中的异常

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12299285/
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-10-31 08:21:10  来源:igfitidea点击:

Exception in WSDL Locator

javawsdlcxf

提问by BKK

I am trying to run a service in a server. But when I run it, it throws the exception below:

我正在尝试在服务器中运行服务。但是当我运行它时,它会抛出以下异常:

javax.wsdl.WSDLException: WSDLException (at /soapenv:Envelope): faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'.
        at com.ibm.wsdl.xml.WSDLReaderImpl.checkElementName(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
        at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:229)
        at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:179)
        at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:91)

Where do I need to put our WSDL file in our project? I have generated the WSDL to Java client code and imported it to my project. In a separate folder, I imported my all WSDL files.

我需要将我们的 WSDL 文件放在我们的项目中的什么位置?我已将 WSDL 生成到 Java 客户端代码并将其导入到我的项目中。在一个单独的文件夹中,我导入了所有 WSDL 文件。

回答by Manan Shah

It looks like your WSDL is not valid. As Andrzej Doyle said, your WSDL might be missing the element or if your WSDL has that element then it contains wrong information. It should look like...

看起来您的 WSDL 无效。正如 Andrzej Doyle 所说,您的 WSDL 可能缺少该元素,或者如果您的 WSDL 具有该元素,则它包含错误的信息。它应该看起来像...

<definitions name="HelloService"
targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl" 
xmlns="http://schemas.xmlsoap.org/wsdl/" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
</definitions>
  • does your targetnamespace tag contain the correct location of wsdl??
  • 你的 targetnamespace 标签是否包含 wsdl 的正确位置?

You can get more information from how-can-i-make-this-a-valid-wsdland wsdl-soap-test-with-soapui

您可以从how-can-i-make-this-a-valid-wsdlwsdl-soap-test-with-soapui获取更多信息

Note: In any case, you have to correct your wsdl. So, please make sure that you have changed your wsdl in both places (In actual wsdl and in your separate folder)

注意:无论如何,您必须更正您的 wsdl。因此,请确保您在两个地方都更改了 wsdl(在实际的 wsdl 和您单独的文件夹中)

回答by Alfergon

In my case the problem was that I was trying to access the WS in the client using a URL like http://foo.bar/ws/WSNameand I needed to use one like http://foo.bar/ws/WSName?WSDL(notice the &WSDLpart).

在我的情况下,问题是我试图使用类似的 URL 访问客户端中的 WS http://foo.bar/ws/WSName,我需要使用类似的http://foo.bar/ws/WSName?WSDL(注意&WSDL部分)。

Hope this helps someone.

希望这可以帮助某人。

回答by Andrzej Doyle

As the exception states, your WSDL is invalid.

正如例外规定,您的 WSDL 无效。

I would hazard a guess that you haven't included a <definitions>element where one was expected/required. But in any case, you need to fix up the WSDL with which you're defining the service.

我会冒险猜测您没有包含<definitions>预期/需要的元素。但无论如何,您都需要修正用于定义服务的 WSDL。