Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring WS without xsd

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

like image 800
user3070136 Avatar asked Jun 20 '15 14:06

user3070136


1 Answers

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.

like image 194
user3070136 Avatar answered Sep 28 '22 10:09

user3070136