Reputation: 121
I'trying to create simple WS project in Spring and Spring WS without any XSD. Deploy on jetty. Is possible to populate WS endpoint and generate WSDL only from java classes (no static XSD or WSDL - I went throught many tutorials but all requiered).
For any help, hint or link highly appreciated.
I have something like this:
1) Request
@XmlRootElement
public class MessageWSRequest {
@XmlElement
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
2) Endpoint
@Endpoint
public class MessageWS {
@PayloadRoot(namespace = "http://message.com/ws/message" ,localPart="MessageWSRequest")
public String handleMathServiceRequest(@RequestPayload MessageWSRequest messageWSRequest) {
return "ok";
}
}
3) springContext.xml
<sws:annotation-driven/>
<context:component-scan base-package="com.ws.message"/>
4) web.xml
<servlet>
<servlet-name>webservices</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>transformWsdlLocations</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>webservices</servlet-name>
<url-pattern>*.wsdl</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>webservices</servlet-name>
<url-pattern>/endpoints/*</url-pattern>
</servlet-mapping>
Now I would expect URL like this localhost:8080/messageTest/endpoints/MessageWS.wsdl with generated WSDL.
Did I miss some configuration or so?
Thanks all
Upvotes: 5
Views: 7700
Reputation: 9154
As you have noted, Spring WS is designed for contract first services. However I think that you can still achieve what you want to do if you generate the XSD during the build process from your annotated classes. Here is one way to do that:
Generating XSD schemas from JAXB types in Maven?
Upvotes: 0
Reputation: 121
Ok, next day a clear mind revelead me this fact: Spring WS offers "only" contract-first, starting from an XSD Schema
I'll use CXF instead: Apache CXF offers both contract-last (starting with Java) and Contract-first (starting with the WSDL) approaches.
Upvotes: 6