简体   繁体   English

用于Java的轻量级SOAP客户端库

[英]Lightweight SOAP Client Library for Java

Can anyone recommend a good Java open source library for building a simple SOAP web service client? 任何人都可以推荐一个好的Java开源库来构建一个简单的SOAP Web服务客户端吗? I'm looking for something with minimal dependencies and configuration that will work in a Java 5 SE environment. 我正在寻找可在Java 5 SE环境中运行的具有最小依赖性和配置的东西。 Upgrading to Java 6 isn't really an option on this project and I'd prefer to avoid using a full J2EE container if I can avoid it. 升级到Java 6并不是这个项目的一个选项,如果我可以避免使用它,我宁愿避免使用完整的J2EE容器。 I don't need to publish and services, only consume. 我不需要发布和服务,只需要消费。

I'm currently using Axis2 but I have to pull in about 15MB of extra jars just to make a simple call to a web service without a NoClassDefFoundError and I'm looking for something with a lot less bloat. 我目前正在使用Axis2,但我必须提供大约15MB的额外罐子才能在没有NoClassDefFoundError的情况下对Web服务进行简单的调用,而且我正在寻找一些不那么臃肿的东西。

I've also looked at CXF, but I'm reluctant to use it because of it's tight coupling to Spring. 我也看过CXF,但我不愿意使用它,因为它与Spring紧密耦合。 Spring isn't a 100% deal breaker, but I'd rather avoid it if possible. Spring不是100%的交易破坏者,但如果可能的话,我宁愿避免它。

Any suggestions? 有什么建议?

Try simple soap-ws library, it is very easy to use. 尝试使用简单的soap-ws库,它非常易于使用。

A lightweight and easy-to-use Java library to handle SOAP on a purely XML level. 一个轻量级且易于使用的Java库,用于在纯XML级别上处理SOAP。

Sample usage 样品用法

 SoapClient client = SoapClient.builder()
    .endpointUri("http://example.com/endpoint")
    .build();

 client.post(envelope);

Dependency 依赖

<dependency>
    <groupId>org.reficio</groupId>
    <artifactId>soap-client</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</dependency>

from repository 来自存储库

<repository>
    <id>reficio</id>
    <url>http://repo.reficio.org/maven/</url>
</repository>

In Spring 3.0 thay have splitted the big spring.jar into modules which will reduce size. 在Spring 3.0中,他们将大spring.jar拆分成了可以减小尺寸的模块。

Check Spring Web Services 检查Spring Web Services

WS Client Example WS客户端示例

The drawback would be that you have to manage dependencies between a lot of jar's this could be become complex if don't want to introduce maven. 缺点是你必须管理很多jar之间的依赖关系,如果你不想引入maven,这可能会变得很复杂。 That was the reason (among others like compatibility problems) why I'm still using axis. 这就是为什么我还在使用轴的原因(其中包括兼容性问题)。

After researching this a while the raw SAAJ API ( https://saaj.dev.java.net/ ) is the only thing I've found that is any more streamlined than the Spring WS library which is built on top of it. 经过一段时间的研究,原始的SAAJ API( https://saaj.dev.java.net/ )是我发现的唯一一个比基于它构建的Spring WS库更精简的东西。 The problem with SAAJ is that it's almost unusable unless you're willing to use their extremely verbose API for building up the XML payload of your message. SAAJ的问题在于,除非您愿意使用极其冗长的API来构建消息的XML有效负载,否则它几乎无法使用。 There are ways to get around this and use something like JAXB to generate the actual message contents, but it's not very clean and Spring WS is essentially just that. 有办法绕过这个并使用类似JAXB的东西来生成实际的消息内容,但它不是很干净,而Spring WS本质上就是这样。

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

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