简体   繁体   English

为没有WSDL的SOAP Web服务构建XML消息

[英]Building XML messages for SOAP web services that don't have a WSDL

I worked in a couple of web service projects with Java. 我曾用Java从事过两个Web服务项目。

Some third parties provide us with their WSDL from which I can generate Java classes using Axis2. 一些第三方为我们提供了他们的WSDL,我可以使用Axis2从中生成Java类。

Other third parties do not provide us with a WSDL, instated they provide use with request and response samples and I have to build the SOAP XML messages using StringBuilder or StringBuffer . 其他第三方未向我们提供WSDL,尽管它们提供了请求和响应样本的使用,但我必须使用StringBuilderStringBuffer构建SOAP XML消息。

Unfortunately, I don't think this is the most efficient or preferred way to build the messages. 不幸的是,我认为这不是构建消息的最有效或首选方式。

Is there any better way to achieve that? 有没有更好的方法来实现这一目标? A way where I do not have to build the SOAP messages using StringBuilder ? 我不必使用StringBuilder构建SOAP消息的方法吗?

If you have a WSDL you can feed it to a tool to generate the client plumbing code (in you case Axis2) so ideally you should obtain one. 如果您有WSDL,则可以将其提供给工具以生成客户端管道代码(在本例中为Axis2),因此理想情况下,您应该获得一个。

First of all you should ask the provider for the WSDL. 首先,您应该向提供程序询问WSDL。 It's a good practice and their responsibility to provide a WSDL and they should build one if their service doesn't yet have it. 这是一个好习惯,也是他们提供WSDL的责任,如果他们的服务尚不具备WSDL,则应该建立一个WSDL。

If still they won't give you a WSDL you can build one yourself , it ain't that difficult if you know what you are doing. 如果他们仍然不给您提供WSDL,则您可以自己构建一个 WSDL,如果您知道自己在做什么,这并不困难。

And if you still can't obtain a WSDL then use a low level API like SAAJ to build the messages. 而且,如果仍然无法获得WSDL,请使用SAAJ之类的低级API来构建消息。 It beats working with StringBuilder or StringBuffer . 胜过使用StringBuilderStringBuffer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM