使用soapui进行WSDL/SOAP测试

发布于 2024-11-14 00:31:54 字数 1852 浏览 0 评论 0原文

我已经用soapui测试了我的网络服务(wsdl/soap)。我有错误: http/log:错误 400 错误请求。

我的 wsdl 可能出现什么错误?

错误/日志:

un Jun 05 14:10:37 CEST 2011:ERROR:javax.wsdl.WSDLException: WSDLException (at /html): faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'.
   javax.wsdl.WSDLException: WSDLException (at /html): 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 com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlInterfaceDefinition.load(WsdlInterfaceDefinition.java:48)
    at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.loadDefinition(WsdlContext.java:66)
    at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.loadDefinition(WsdlContext.java:30)
    at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext.cacheDefinition(AbstractDefinitionContext.java:264)
    at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext.access$400(AbstractDefinitionContext.java:44)
    at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:230)
    at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
    at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:140)
    at java.lang.Thread.run(Thread.java:637)

I have tested my web services (wsdl/soap) with soapui. and i have the errors :
http/log : error 400 BAD REQUEST.

What can be the error please with my wsdl ?

error/log :

un Jun 05 14:10:37 CEST 2011:ERROR:javax.wsdl.WSDLException: WSDLException (at /html): faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'.
   javax.wsdl.WSDLException: WSDLException (at /html): 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 com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlInterfaceDefinition.load(WsdlInterfaceDefinition.java:48)
    at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.loadDefinition(WsdlContext.java:66)
    at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.loadDefinition(WsdlContext.java:30)
    at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext.cacheDefinition(AbstractDefinitionContext.java:264)
    at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext.access$400(AbstractDefinitionContext.java:44)
    at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:230)
    at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
    at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:140)
    at java.lang.Thread.run(Thread.java:637)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

凉宸 2024-11-21 00:31:54

definitions 是 WSDL 的根元素,因此看起来您没有加载 WSDL。

编辑:

我测试了它,看起来整个问题出在你的网络服务器上。您的 Web 服务器将 WSDL 返回给浏览器,但不会将其返回给任何工具,因为这些工具使用非常简约的 HTTP 请求,没有许多 HTTP 标头。缺少的标头之一是 Accept。一旦请求中不包含此标头,您的服务器就会抛出 HTTP 400 Bad 请求。

继续的简单方法是在浏览器中打开 WSDL,将 wsdl 保存到文件中,然后将该文件导入到soapUI,而不是从 URL 导入 WSDL。

definitions is a root element of WSDL so it looks like you are not loading WSDL.

Edit:

I tested it and it looks like the whole problem is with your web server. Your web server returns WSDL to browser but it doesn't return it to any tool because these tools are using very minimalistic HTTP requests without many HTTP headers. One of missing headers is Accept. Once this header is not included in the request your server throws HTTP 400 Bad request.

The easy approach to continue is opening WSDL in the browser, save the wsdl to a file and import that file to soapUI instead of the WSDL from URL.

无所的.畏惧 2024-11-21 00:31:54

另一种可能性是您需要在 SoapUI 的服务 url 末尾添加 ?wsdl。
这个让我很感动,因为我习惯了 WCFClient,它不需要它。

Another possibility is that you need to add ?wsdl at the end of your service url for SoapUI.
That one got me as I'm used to WCFClient which didn't need it.

獨角戲 2024-11-21 00:31:54

您可以尝试在 Web 浏览器中打开 wsdl 并使用 .wsdl 扩展名保存。并将 SOAP UI 项目中的 WSDL 设置为此 .wsdl 文件。
这确实有效。

You can try opening the wsdl in web browser and saving with .wsdl extension. And set the WSDL in SOAP UI project to this .wsdl file.
This really works.

数理化全能战士 2024-11-21 00:31:54
  • 是的,首先确保您将“?wsdl”添加到“http......whatever.svc”链接中。

    • 但这并没有解决我的问题。我必须从头开始创建一个新的 WCF 项目并手动复制代码。这解决了它。祝你好运。

最重要的是!

当您更改代码中的命名空间时,还请确保在 web.config 中更改它!

  • yes, first ensure you added "?wsdl" to your "http......whatever.svc" link.

    • That didn't fix my problem, though. I had to create a new WCF project from the beginning and manually copy the code. That fixed it. Good luck.

And most important!!!

When you change a namespace in your code, also make sure you change it in web.config!

捂风挽笑 2024-11-21 00:31:54

我在尝试测试部署到 WSO2 ESB 的 Web 服务时遇到了同样的异常。

WSO2 生成 wsdl 和 wsdl2。我尝试传递 wsdl2 URL 并得到上述异常。快速谷歌搜索告诉我,wsdl1.1 和 wsdl2.0 之间的区别之一是将“定义”元素替换为“描述”。另外,我发现 SoapUI 不支持 wsdl2

因此,对我来说,解决方案是使用 wsdl1 url 而不是 wsdl2。

I faced the same exception while trying to test my web-services deployed to WSO2 ESB.

WSO2 generated both wsdl and wsdl2. I tried to pass a wsdl2 URL and got the above exception. Quick googling showed me, that one of differences between wsdl1.1 and wsdl2.0 is replacing 'definitions' element with 'description'. Also, I found out, that SoapUI does not support wsdl2.

Therefore, for me the solution was to use wsdl1 url instead of wsdl2.

夏日落 2024-11-21 00:31:54

一种可能的可能性是您的浏览器通过代理访问您的 Web 服务,而 SoapUI 未配置为使用该代理。例如,我在公司环境中工作,虽然我的 IE 和 FireFox 可以访问外部网站,但我的 SoapUI 只能访问内部 Web 服务。

简单的解决方案是在浏览器中打开 WSDL,将其保存到 .xml 文件,然后将您的 SoapUI 项目建立在该文件的基础上。但是,如果您的 WSDL 依赖于它无法访问的外部 XSD,则此方法将不起作用。

A likely possibility is that your browser reaches your web service through a proxy, and SoapUI is not configured to use that proxy. For example, I work in a corporate environment and while my IE and FireFox can access external websites, my SoapUI can only access internal web services.

The easy solution is to just open the WSDL in a browser, save it to a .xml file, and base your SoapUI project on that. This won't work if your WSDL relies on external XSDs that it can't get to, however.

浪菊怪哟 2024-11-21 00:31:54

对于将来遇到此问题的任何人:此处的具体情况(“服务器未正确发回 WSDL”)可能始终相关,也可能不始终相关,但两个关键方面始终应该是:

  1. 消息 faultCode= INVALID_WSDL:预期元素 '{http://schemas.xmlsoap.org/wsdl/}definitions' 表示返回的实际内容不是在 WSDL 命名空间中具有“definitions”基本元素的 XML。
  2. 消息 WSDLException (at /html) 告诉您一条关于它发现了什么的重要线索 — 对于本例,/html 强烈暗示返回的是正常网页,而不是 WSDL。另一种常见情况是看到类似 /soapenv:Reason 的内容,这表明服务器正在尝试将其视为 SOAP 调用 - 例如,如果您的 URL 用于“base”,则可能会发生这种情况服务 URL 而不是 WSDL。

For anyone hitting this issue in the future: the specific situation here ("the server isn't sending back the WSDL properly") may or may not always be relevant, but two key aspects should always be:

  1. The message faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions' means that the actual content returned is not XML with a base element of "definitions" in the WSDL namespace.
  2. The message WSDLException (at /html) tells you an important clue about what it did find — for this example, /html strongly implies that a normal webpage was returned, rather than a WSDL. Another common situation is seeing something like /soapenv:Reason, which would indicate that the server was trying to treat it as a SOAP call — for example, this can happen if your URL is for the "base" service URL rather than the WSDL.
夜清冷一曲。 2024-11-21 00:31:54

我遇到了同样的问题,解决方案(对我来说)是:

  • 打开 SoapUI 首选项,
  • 单击 SSL 设置,
  • 清除 KeyStore 和 KeyStore 密码文本框,
  • 取消选中客户端身份验证底部的复选框,需要客户端身份验证。

I had the same problem, and the solution (for me) was to:

  • open SoapUI Preferences
  • click on SSL Settings
  • clear out the KeyStore and KeyStore Password text boxes
  • untick the bottom checkbox for Client Authentication, requires client authentication.
在巴黎塔顶看东京樱花 2024-11-21 00:31:54

在以 .svc 结尾的 AspNet 服务上,您必须将 URL 终止为“?wsdl”。
否则,SoapUI 将尝试读取服务的登陆页面 HTML(这不是 WSDL,对吧?)

例如:
http://localhost:1234/WebServices/WsBlahBlahBlah.svc?wsdl

On AspNet services with .svc endding you must terminate URL as "?wsdl".
Otherwise, SoapUI will try to read the land page HTML of the Service (that is not a WSDL, right?)

Eg.:
http://localhost:1234/WebServices/WsBlahBlahBlah.svc?wsdl

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文