简体   繁体   中英

Lightweight SOAP Client Library for Java

Can anyone recommend a good Java open source library for building a simple SOAP web service client? I'm looking for something with minimal dependencies and configuration that will work in a Java 5 SE environment. 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. 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.

I've also looked at CXF, but I'm reluctant to use it because of it's tight coupling to Spring. Spring isn't a 100% deal breaker, but I'd rather avoid it if possible.

Any suggestions?

Try simple soap-ws library, it is very easy to use.

A lightweight and easy-to-use Java library to handle SOAP on a purely XML level.

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.

Check Spring Web Services

WS Client Example

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. 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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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