简体   繁体   English

如何使用spring-boot创建服务第一个soap webservice

[英]How to create service first soap webservice using spring-boot

We can see many tutorials that shows how to produce soap webservice using xsd in spring-boot. 我们可以看到许多教程,展示如何在spring-boot中使用xsd生成soap webservice。 Is it possible to create soap webservice without xsd and from plain Java code using spring-boot-webservice module like we do using @webservice annotation in jax-ws 是否可以使用spring-boot-webservice模块创建没有xsd的soap webservice和纯Java代码,就像我们在jax-ws中使用@webservice注释一样

Guides like this start with an xsd file because they use xjc to create java classes from the XSD definition. 这样的指南以xsd文件开头,因为它们使用xjc从XSD定义创建java类。 xjc creates classes with JaxB annotations (javax.xml.bind.annotation). xjc使用JaxB注释(javax.xml.bind.annotation)创建类。 JaxB is an xml binding specification that has been part of the JDK since 1.6, and it requires that all types from the xsd exist as java classes. JaxB是一个xml绑定规范,从1.6开始就是JDK的一部分,它要求xsd中的所有类型都作为java类存在。

I suggest that you do a tutorial that starts with an xsd an take a look at the auto generated classes. 我建议你做一个以xsd开头的教程,看看自动生成的类。 There is nothing to prevent you from writing you own classes instead of generating them from a wsdl, and if you don't refer to external schemas I prefer to do the code only approach (I hate xml configuration). 没有什么可以阻止你编写自己的类而不是从wsdl生成它们,如果你没有引用外部模式,我更喜欢仅使用代码方法(我讨厌xml配置)。

If you look at the tutorial, the gradle task "getJaxb" will create .java files into "build/generated-sources" compile them and copy them into "build/classes" if you copy the *.java files into "src/main/java" (keep the package structure) and delete delete/disable the "genJaxb" task in gradle, and delete your build folder, everything still works (it actually works better since you normally have red lines in your IDE because the XML beans don't exist until you run the generator the first time). 如果你看一下教程,gradle任务“getJaxb”会将.java文件创建成“build / generated-sources”编译它们并将它们复制到“build / classes”中,如果你将* .java文件复制到“src / main”中/ java“(保留包结构)并删除删除/禁用gradle中的”genJaxb“任务,并删除你的构建文件夹,一切仍然有效(它实际上工作得更好,因为你的IDE中通常有红线,因为XML bean没有直到你第一次运行发电机才存在。

Now all you need to do is master the JaxB annotations, so you can write your own beans. 现在您需要做的就是掌握JaxB注释,这样您就可以编写自己的bean了。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM