Costruire un WS con la primavera
-
29-09-2019 - |
Domanda
Ho bisogno di creare un WS con la primavera 3.0.4.RELEASE per l'esecuzione in un Tomcat con Axis2. Sto seguendo questo documento: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/remoting.html#remoting-web-services-jaxws-export- RI (se detto paragrafo può essere chiamato "doc")
Ok, ecco i dettagli:
La classe Java:
package foo;
@WebService(serviceName="MyService")
public class MyService{
@WebMethod
public String getString(){
return "Hello StackOverflow";
}
}
Il WEB-INF / primavera-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>
Il 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>
E per ultimo, ma non meno importante, la Errore quando avviare 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]
Qualcuno ha qualche idea di ciò che sta accadendo? È tutto la configurazione corretta? Qualcuno ha un semplice (di lavoro) WS per mostrare come distribuire WS usando Primavera?
Grazie in anticipo
Soluzione
Ho anche esperienza di questo problema un po 'indietro e capito il problema è con il "https: //". Cambiare di nuovo a http: // e si dovrebbe essere pronti per partire. Ma quando si utilizza http: // si ottiene un errore di convalida dello schema in Eclipse, perché Eclipse non può automaticamente reindirizzamento schema url da http: // a https: //. E a quanto pare NetBeans è in grado di farlo.
Ancora una cosa. Dovrete avere il xbeans molla pure. Onestamente penso che è una dipendenza abbastanza stupido.