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

查看:378
本文介绍了使用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天全站免登陆