Reputation: 3409
I'm creating a WSDL-first webservice with spring-ws in gradle.
Some examples I have been looking at (e g https://spring.io/guides/gs/producing-web-service/ ) it seems they will only generate the java-classes from the XSD-schema, but no java-interface (or abstract-class) from the WSDL service-operations?
Also, in the spring-ws doc, it says "... in Spring-WS, writing the WSDL by hand is not required ...".
Is it correctly understood that spring-ws will not generate any java-interface or class for the actual service itself?
Is it possible to override this default behaviour and force it to do so?
I would like to ensure the full WSDL is correctly and completely implemented...
Upvotes: 2
Views: 5061
Reputation: 259
If you want only interfaces from WSDL just use wsimport command. Its part of jdk so no extra things needed.
run the commend: wsimport -keep wsdlUrl it will generate all the interfaces and client code (.java as well as .class)to hit the web service. just search your interface.
Let your generated URL is :http://www.host.com/testservice?WSDL
then commend will be wsimport -keep http://www.host.com/testservice?WSDL there are much more options with wsimport commend use as you want. http://docs.oracle.com/javase/7/docs/technotes/tools/share/wsimport.html
Upvotes: 1
Reputation:
ws import generate all the client side code. asn wellm as much more things try wsimport, wsgen for more details
Upvotes: 0
Reputation: 4233
With spring-ws you can build contract first WS, although it is not necessary to build your WSDL, because it can generate it dynamically.
For java objects, spring-ws allows you to marshall/unmarshall using jaxb2 or similar. This way, you can obtain java classes from XSD, but this code generation is made by the marshaller.
From a server point of view, you create WS Endpoints that match WSDL operations. That Endpoints are annotated and bound to a request/response java objects. Thus, spring can generate dynamically WSDL, but you can use your own WSDL.
From a client point of view, you need a WSTemplate
that needs to retrieve a WSDL (static or dynamic, it doesn't mind). Using this way, WSTemplate
ensure you can call all server endpoints, without implementing client stubs or generated code.
I rather prefer to use static WSDL, because dynamic generation can't ensure that your WSDL change if you upgrade Spring or so, and this could break compatibility with your clients.
However, while I am developing I use dynamic WSDL, for the shake of simplicity. Once I have the service I want, I get dynamically generated WSDL (customize if I need) and use it as static. That WSDL is full for all the endpoints.
Hope it helps!
Upvotes: 1