将 WSDL 转换为其各自的 HTTP 绑定

发布于 2024-12-28 16:41:05 字数 566 浏览 0 评论 0原文

我只是尝试根据 WSDL 提供的数据将 WSDl 转换为许多不同的 HTTP 请求。我读过很多类似的问题,但没有一个真正提供答案。

有人说使用 SOAPUI - 我熟悉这个应用程序并且确实使用它。但我需要自己从 WSDL 创建这些 HTTP 请求。

有人说尝试 JAXWS - 我查看了许多关于此以及 Axis 的教程,这些教程将 WSDL 转换为 Java 类绑定,您可以使用这些方法来测试网络服务。我真的很想自己生成 HTTP 请求,以便在某一时刻我可以操纵该请求并发送我自己的测试。

我开始使用 wsdl4j 自己开始解析 WSDL,但在我完全确定我不会重新发明轮子之前,我宁愿不走这条路。在我看来,过去有这个必要吗?但是对于 WSDL4J 和其他所有库,我没有看到 WSDL 到 Soap 消息的转换。

任何建议都会非常有帮助。目标是我希望能够获取 WSDL、检查它并为 WSDL 中的每个方法创建 HTTP-SOAP 请求,然后能够测试它们的安全问题。第一步是创建这些请求!

I'm simply trying to convert a WSDl into a number of different HTTP-requests from data supplied by the WSDL. I have read through a ton of similar questions, but none really provided an answer.

Some say to use SOAPUI - I am familiar with this application and do use it. But I need to create these HTTP-requests from the WSDL on my own.

Some say to try JAXWS - I looked at a number of tutorials on this as well as on Axis and these translate the WSDL into Java class bindings and you use those methods to test the web services. I really would like to just generate the HTTP-request myself so that at one point I can manipulate the request and send my own tests.

I started using wsdl4j to begin parsing the WSDL myself but would rather not go down this path until I'm absolutely sure I'm not reinventing the wheel. Seems to me there has been a need for this in past? But with WSDL4J and every other library I do not see a WSDL to Soap message translation.

Any suggestions would be very helpful. The goal is I want to be able to take a WSDL, examine it and create HTTP-SOAP requests for each method in the WSDL and be able to than test them for security issues. The first step is to create those requests!

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

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

发布评论

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

评论(1

弥繁 2025-01-04 16:41:05

调用 SOAP Web 服务时,您可以使用静态调用或动态调用。

静态调用意味着从 WSDL 创建存根并使用它来执行调用。这会为您创建所有“管道”代码,但与该 Web 服务紧密相关,并且您不能将其用于具有不同合同的其他 Web 服务。对于每个 WSDL,您需要创建另一个存根。

通过动态调用,您可以在运行时读取 WSDL,并根据从 WSDL 获得的信息了解如何调用 Web 服务。向其提供多个 WSDL,客户端就会进行调整。

SoapUI 使用动态调用来生成示例请求和响应。

它读取您提供给它的 WSDL,从类型部分提取 XML 模式并生成 XML 实例。为此,它使用 Wsdl4jXmlBeans 在底层。

使用 Wsdl4j 的决定是好的,因为它可以让您在解析 WSDL 时进行控制。但还要看看 XmlBeans;它还有一些其他工具,您可能会发现有用,例如 <一个href="http://svn.apache.org/viewvc/xmlbeans/trunk/src/tools/org/apache/xmlbeans/impl/xsd2inst/SchemaInstanceGenerator.java?revision=149478&view=markup&sortby=log" rel例如,="nofollow">实例的架构类。

如果您需要查看它的运行情况(也许对其进行调试以查看发生了什么),您可以使用 SoapUI API 创建一个快速脏测试:

import com.eviware.soapui.impl.wsdl.WsdlInterface;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlImporter;

public class Test {
    public static void main(String[] args) throws Exception {
        WsdlProject project = new WsdlProject();
        WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, "http://www.html2xml.nl/Services/Calculator/Version1/Calculator.asmx?wsdl");
        WsdlInterface wsdl = wsdls[0];
        System.out.println(wsdl.getOperationByName("Add").createRequest(true));
        System.exit(0); // just to clear up some threads created by the project 
    }
}

您应该看到打印的消息(对于计算器 WS 的添加操作)将类似于this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:Add>
         <tem:a>?</tem:a>
         <tem:b>?</tem:b>
      </tem:Add>
   </soapenv:Body>
</soapenv:Envelope>

希望这可以帮助您超越第一步。

When calling a SOAP web service you can use a static invocation or a dynamic invocation.

Static invocation means creating a stub from the WSDL and using that to perform the call. This creates all the "plumbing" code for you, but is tightly tied to just that web service and you can't use it for other web services with different contracts. For each WSDL you need to create another stub.

With dynamic invocation, you read the WSDL at runtime and figure out how to call the web service based on the info you get from the WSDL. Feed it multiple WSDLs and the client adapts.

The dynamic invocation is what SoapUI uses to generate the sample requests and responses.

It reads the WSDL you feed it, extracts the XML schema from the types section and generates XML instances. To do so, it uses Wsdl4j and XmlBeans under the hood.

Your decision to use Wsdl4j is good as it gives you control when parsing the WSDL. But also have a look at XmlBeans; it has some other tools you might find useful, like the schema to instance class for example.

If you need to see it in action (maybe debug it to see what's going on) you could create a quick dirty test with the SoapUI API:

import com.eviware.soapui.impl.wsdl.WsdlInterface;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlImporter;

public class Test {
    public static void main(String[] args) throws Exception {
        WsdlProject project = new WsdlProject();
        WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, "http://www.html2xml.nl/Services/Calculator/Version1/Calculator.asmx?wsdl");
        WsdlInterface wsdl = wsdls[0];
        System.out.println(wsdl.getOperationByName("Add").createRequest(true));
        System.exit(0); // just to clear up some threads created by the project 
    }
}

The message you should see printed (for the Add operation of the Calculator WS) would be something like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:Add>
         <tem:a>?</tem:a>
         <tem:b>?</tem:b>
      </tem:Add>
   </soapenv:Body>
</soapenv:Envelope>

Hope this helps you move beyond the first step.

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