使用 Maven 来自 WSDL 的简单(独立)Java SOAP Web 服务客户端 [英] Simple (standalone) Java SOAP web service client from WSDL using Maven

查看:31
本文介绍了使用 Maven 来自 WSDL 的简单(独立)Java SOAP Web 服务客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望生成一个简单的独立 Java 客户端,在给定 wsdl 的情况下,它将调用 SOAP Web 服务.当我说简单和独立时,我的意思是一旦我完成,我希望能够做一些像

I'm looking to generate a simple standalone Java client which will make calls to a SOAP web service, given a wsdl. When I say simple and standalone I mean that once I'm done I want to be able to do something like

import my.generated.nonsense;

public static void main(String[] args) {
    Client client = new Client();
    client.getSomething();
}

我最近在其他一些项目中与 Maven 一起玩得很开心,我想保持这种状态,所以打算在这里使用它.除了允许我执行上述操作的类之外,我不希望该工具生成任何内容.

I've had great time recently with Maven on some other projects and I want to keep that going, so would aim to use it here. I don't want the tool to generate anything expect the classes that allow me to do the above.

最近有人做过这个并且可以推荐一个 ws 库和 Maven 插件吗?谢谢.

Anyone done this recently and can recommend a ws library and Maven plugin? Thanks.

推荐答案

看看 CXF 及其 Maven 插件.CXF 会生成类似于您的代码(当然 Web 服务可能会失败,您应该添加异常处理).请记住,尽管 SOAP Web 服务是一个复杂的主题,并且生成的代码中的简单性可能并不总是可取的.使用默认设置生成客户端可能不适用于某些客户端.然后,您需要调整代码生成的配置和/或添加代码来处理它.CXF 既适用于简单/默认客户端,也适用于更复杂的客户端.

Have a look at CXF and its Maven plug in. CXF would generate code similar to yours (of course web services could fail and you should add exception handling). Have in mind though that SOAP web services is a complicated topic and simplicity in the generated code may not be always desirable. Generating a client with the default settings may not work for some clients. You would then need to tweak the configuration of the code generation and/or add code to handle it. CXF is good both for easy/default clients and more complicated ones.

这篇关于使用 Maven 来自 WSDL 的简单(独立)Java SOAP Web 服务客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆