Spring Boot 中的 SOAP 服务

我对我被迫在 Spring Boot 中创建 SOAP 服务的方式感到困惑。过去我用Java写了很多SOAP服务,只是把java代码写下来,没有一行XML。一种非常简单且错误较少的方法。我为 Spring Boot 阅读的所有教程都需要编写一个 XSD 文档,maven 将读取并构建所需的类。

Spring Boot 是否支持绕过 XSD 文件并直接编写所需的 Java 类的方法?


炎炎设计
浏览 323回答 1
1回答

小怪兽爱吃肉

我相信,当您开发大型服务或具有大量对象的服务时,编写 XML 代码来生成 Java 代码非常容易出错,而且代码维护起来非常困难。如果你有一个小项目,一切都很好,这不是我的情况。我所做的是编写类,然后使用schemagen生成 xsd 文件。这是我在 maven pom 中添加的配置:&nbsp;<plugin>&nbsp; &nbsp; &nbsp;<groupId>org.codehaus.mojo</groupId>&nbsp; &nbsp; &nbsp;<artifactId>jaxb2-maven-plugin</artifactId>&nbsp; &nbsp; &nbsp;<version>2.4</version>&nbsp; &nbsp; &nbsp;<executions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<id>schemagen</id>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<goal>schemagen</goal>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</execution>&nbsp; &nbsp; &nbsp;</executions>&nbsp; &nbsp; &nbsp;<configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <outputDirectory>${basedir}/src/main/resources/xsds/</outputDirectory>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <transformSchemas>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <transformSchema>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <uri>http://test/test-ws/MyTestSchema</uri>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <toPrefix>test</toPrefix>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <toFile>test.xsd</toFile>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </transformSchema>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</transformSchemas>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<sources>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<source>${basedir}/src/main/java/my/classes/</source>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</sources>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<verbose>true</verbose>&nbsp; &nbsp; &nbsp;</configuration>&nbsp;</plugin>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java