Construire un WS avec Spring
-
29-09-2019 - |
Question
Je dois créer un WS avec Spring 3.0.4.RELEASE à exécuter dans un Tomcat avec Axis2. Je suis ce document: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/remoting.html#remoting-web-services-jaxws-export- ri (si ce paragraphe peut être appelé "doc")
Ok, voici les détails:
La classe java:
package foo;
@WebService(serviceName="MyService")
public class MyService{
@WebMethod
public String getString(){
return "Hello StackOverflow";
}
}
Le WEB-INF / ressort ws.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://jax-ws.dev.java.net/spring/core https://jax-ws.dev.java.net/spring/core.xsd
http://jax-ws.dev.java.net/spring/servlet https://jax-ws.dev.java.net/spring/servlet.xsd">
<wss:binding url="/myService" service="#myService" />
<ws:service id="myService"
impl="foo.MyService" />
</beans>
Le WEB-INF / web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="myService" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>my Service</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-ws.xml</param-value>
</context-param>
<!-- this is for Spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- these are for JAX-WS -->
<servlet>
<servlet-name>jaxws-servlet</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>jaxws-servlet</servlet-name>
<url-pattern>/myService</url-pattern>
</servlet-mapping>
Et enfin, mais pas moins important, le erreur quand je commence tomcat 6.0.29 :
Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://jax-ws.dev.java.net/spring/servlet]
Offending resource: ServletContext resource [/WEB-INF/spring-ws.xml]
Quelqu'un a une idée de ce qui se passe? Est-ce la configuration correcte? Quelqu'un at-il un simple (travailler) WS pour montrer comment déployer un WS avec Spring?
Merci à l'avance
La solution
Je ressens aussi cette question un certain temps et compris le problème est avec le « https: // ». Changer de nouveau à http: // et vous devriez être bon d'aller. Mais lorsque vous utilisez http: // vous obtenez une erreur de validation de schéma dans Eclipse, car l'éclipse ne peut pas url schéma Rediriger automatiquement à partir de http: // https: //. Et apparemment, NetBeans est capable.
Une autre chose. Vous devez avoir le xbeans ressort ainsi. Honnêtement, je pense que c'est une dépendance assez stupide.