如何构建一个暴露休息和肥皂服务的弹簧靴罐 [英] how to build a spring boot jar exposing both rest and soap service

查看:25
本文介绍了如何构建一个暴露休息和肥皂服务的弹簧靴罐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在考虑为开发人员社区构建一个测试 jar,以便公开 API 下一个版本的预览(让存根以准确的格式返回预期的响应等).我们确实有 REST 和 SOAP API.我想构建 REST 服务不会有任何问题,因为网络上充斥着示例.令人惊讶的是,关于如何使用带有嵌入式码头的 Spring Boot 构建 SOAP 服务 (JAXWS) 的具体示例并不多.

I have been contemplating on building a test jar for a community of developers in order to expose a preview of a next release of an API (having stubs returning expected response with exact format etc). We do have both REST and SOAP API. I guess it won't be any problem building the REST Service as the net is flooded with example. It was quite surprising there isn't much of concrete example of how to build SOAP service (JAXWS) with spring boot with embedded jetty.

我期望实现的是具有两个 API 的单个 jar.我很乐意开发 Java 优先服务.我在 stackoverflow 中看到了一个帖子,但它没有没有明确概述实现这一目标的步骤.我知道这是可能的,因为 dropwizard 家伙有类似的项目.

What I expect to achieve is one single jar with both APIs. I am rather comfortable developing a java first services. I have seen a post in stackoverflow but it doesn't clearly outline steps to achieve that. I know it's possible because dropwizard guys have similar project.

如果有关于如何在 Spring Boot 中处理 SOAP Web 服务的示例资源,我将不胜感激.

I will be grateful if there is any resource with example on how to handle SOAP web services in spring boot.

提前致谢

推荐答案

Spring 已经通过 *JaxWsServiceExporterSpringBeanAutowiringSupport(在 spring-web 中)支持 JAXWS.*Exporter 方法与 REST 内容不太吻合,因为它不在嵌入式容器中.您最终会得到一个监听 2 个端口的应用程序(一个用于 XML,一个用于 JSON).如果其中任何一个有效,那么您就有了解决方案.如果您不太关心 SOAP 并且只想要 XML 表示,您可以使用普通的内容协商功能(例如 @ResponseBody@RestController 用于所有内容).

Spring already supports JAXWS through *JaxWsServiceExporter and SpringBeanAutowiringSupport (in spring-web). The *Exporter approach doesn't quite mesh with the REST stuff because it isn't in the embedded container. You'd end up with an app listening on 2 ports (one for XML and one for JSON). If either of those works then you have a solution. If you don't really care that much about SOAP and just want XML representations, you can use normal content negotiation features (e.g. @ResponseBody or @RestController for everything).

这篇关于如何构建一个暴露休息和肥皂服务的弹簧靴罐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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