I have WSDL and schema files provided by client. I need to create Spring-boot SOAP web service with this WSDL file. I have google it and all the examples that I can find, they have auto-generate the wsdl with spring.How can I use my WSDL to generate the SOAP service?
相关问题
- Dependency injection into Logback Appenders with S
- Deserialize duplicate keys to list using Jackson
- How can I access the repository from the entity in
- Prevent Swagger from automatically adding some mod
- Creating Unknown Number of Beans With Configuratio
相关文章
- How to load @Configuration classes from separate J
- Using Spring Dynamic Languages Support from Groovy
- Spring JMS : Set ErrorHandler for @JmsListener ann
- Cannot use org.jvnet.jax-ws-commons.jaxws-maven-pl
- ModelMapper: Choose mapping based on Child class
- PHP SoapClient constructor very slow
- Configure Spring for CORS
- Remove transitive classpath dependency in gradle
You can create WebServiceConfiguration java class in your packages.
After run as spring boot app...then copy paste this url in your browser. http://localhost:8080/ProjectName/wsdlname.wsdl
noted:localhost:8080 to replace with your tomcat port
SOAP (originally Simple Object Access Protocol) is a protocol specification for exchanging structured information in the implementation of web services in computer networks. SOAP allows processes running on disparate operating systems (such as Windows and Linux) to communicate using Extensible Markup Language (XML). SOAP can be used in conjunction with WSDL which is standardized what means that people who know the standard (WSDL) can learn from it what operations a web service offers and how data is exchanged. This knowledge can be used to create tools that generate type safe binder classes/objects out of the WSDL file. These generated classes (to make RPCs) can be used without needing to manually implementing the requests and encoding/parsing of the data that is exchanged.
Using maven-jaxb2-plugin we can generate the required classes required from wsdl.
Next using the ServletRegistrationBean we register the MessageDispatcherServlet with Spring Boot. During this registration the servlet mapping URI pattern is set to /javainuse/ws/*. Using this path, the web container will map incoming HTTP requests to the MessageDispatcherServlet. The DefaultWsdl11Definition exposes a standard WSDL 1.1 using the specified Hello World WSDL file. MessageDispatcherServlet also automatically detects any WsdlDefinition defined in its application context.
The detailed explaination along with video tutorial is available here- Spring Boot + SOAP Web Services Contract First Example
Here are the common steps to follow to use your existing wsdl with Spring-Ws and Spring-boot.
Config class
The easiest way is to simply use the cxf-spring-boot-starter incl. it's companion Maven plugin, they will take care of generating mostly everything needed from your wsdl and schema files. Here's a full example: https://github.com/codecentric/spring-samples/tree/master/cxf-boot-simple.
Using the starter in your
pom.xml
, you just have to place the wsdl & schema files insrc/main/resources
and your're mostly done. Here's a full example pom.xml:There are a number of options for exposing a web service starting from a WSDL file and using Spring Boot. You would typically generate your Java classes from the WSDL definition. There are a number of JAXB Maven plugins that will support you in doing this.
In addition when using Spring Boot make sure you take advantage of the spring-boot-starters in order to automatically manage the different needed dependencies.
One approach is to use Spring Web Services in combination with the
maven-jaxb2-plugin
plugin. I've created a step by step tutorial which explains how to do this using Spring-WS starting from a WSDL file for both consumer and provider.Another alternative is to use a framework like Apache CXF in combination with the
cxf-codegen-plugin
plugin. CXF also comes with it's own CXF Spring Boot starter calledcxf-spring-boot-starter-jaxws
. In order to get you started I've compiled an example which uses the CXF starter in combination with Spring Boot to create a web service starting from a WSDL file.