简体   繁体   English

使用Maven从WSDL获得的简单(独立)Java SOAP Web服务客户端

[英]Simple (standalone) Java SOAP web service client from WSDL using Maven

I'm looking to generate a simple standalone Java client which will make calls to a SOAP web service, given a wsdl. 我希望生成一个简单的独立Java客户端,它将在给定wsdl的情况下调用SOAP Web服务。 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();
}

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. 我最近和Maven在其他一些项目上玩得很开心,我想继续这样做,所以我的目标就是在这里使用它。 I don't want the tool to generate anything expect the classes that allow me to do the above. 我不希望该工具生成任何期望允许我执行上述操作的类。

Anyone done this recently and can recommend a ws library and Maven plugin? 最近有人这么做了,可以推荐一个ws库和Maven插件吗? Thanks. 谢谢。

Have a look at CXF and its Maven plug in . 看看CXF及其Maven 插件 CXF would generate code similar to yours (of course web services could fail and you should add exception handling). CXF会生成与您类似的代码(当然,Web服务可能会失败,您应该添加异常处理)。 Have in mind though that SOAP web services is a complicated topic and simplicity in the generated code may not be always desirable. 请记住,SOAP Web服务是一个复杂的主题,生成的代码中的简单性可能并不总是令人满意。 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. CXF适用于简单/默认客户端和更复杂的客户端。

I would recommend SOAP UI for what you need to do. 我建议您使用SOAP UI来完成您需要做的事情。 You do not need to write any code - you can call the web service from the soap UI client. 您不需要编写任何代码 - 您可以从soap UI客户端调用Web服务。

If you need to automate making soap calls you can use the maven plugin as part of your build/deploy process. 如果您需要自动化肥皂调用,您可以使用maven插件作为构建/部署过程的一部分。 More info about the maven plugin here: http://www.soapui.org/Test-Automation/maven-2x.html 有关maven插件的更多信息,请访问: http//www.soapui.org/Test-Automation/maven-2x.html

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

相关问题 在Java中从WSDL创建Web服务客户端 - Creating a web service client from WSDL in java 从Java中的WSDL导入Web服务客户端 - Import a Web Service Client from a WSDL in Java 从 WSDL 生成 Java Web 服务客户端 - Generate Java web service client from WSDL 使用不带WSDL的Java的肥皂客户端服务-如何? - Soap client service using java without WSDL - How to? 无法在带有WSDL的Java中使用SOAP Web服务从数据库检索数据(glassfish服务器) - Can't retrieve data from database using SOAP web service in java with WSDL (glassfish server) 如何使用Eclipse在Core Java中使用WSDL文件(WSDL文件使用SOAP)创建Web服务? - How to create Web Service using WSDL file (WSDL file is using SOAP) in Core Java using Eclipse? 使用wsdl2java和Spring的Web服务客户端 - Web service client using wsdl2java and Spring 从.wsdl中为Java生成Web服务客户端安全策略 - Generate web service client secure policy from .wsdl for java 在没有WSDL2OBJC和Sudz C的情况下,将Java中的Web服务与SOAP客户端目标C连接起来? - Connect Web Service in Java with SOAP Client Objective C without WSDL2OBJC and Sudz C? 如何创建一个完整的Java Soap Web服务(jax-rpc)项目(不仅仅是客户端代码)一个wsdl文件? - How to create a complete java soap web service (jax-rpc) project (not just client code) a wsdl file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM