Voir message n°4 SVP
Version imprimable
Voir message n°4 SVP
Je en comprends pas pourquoi tu as besoin de Spring, de CXF, et Tomcat. Si tu débutes, prends une implémentation JAX-RS (le standard pour les WS RESTful, utilisation de POJO) et utilise simplement le JDK - https://jersey.dev.java.net/use/getting-started.html
Merci pour ta réponse.
C'est dans le cadre de mon projet que j'ai besoin de ces technos : Spring, CXF et Tomcat.
Depuis cette erreur, j'ai réussi à avancer : j'ai intégré CXF à Spring et compiler le tout dans un war pour Tomcat.
Aujourd'hui, je suis coincé sur un autre problème : je n'arrive pas à appeler mon webservice !
Je vous donnerai d'autres détails un peu plus tard...
J'ai donc suivi les étapes présentes sur le site officiel
http://cwiki.apache.org/CXF20DOC/http-binding.html
1/ Ajouter l'annotation @Webservice à mon interface
Je l'ai également fait sur mon Impl mais je ne suis pas sûr qu'il faille le faire :Code:
1
2 @WebService public interface ProcessService {
2/ Dans mon interface, j'ai ajouté une annotation @Get, @HttpResource, @WebParam à la méthode que je souhaite exposer au webserviceCode:
1
2
3
4
5 @WebService( endpointInterface = "xxxxxxxxx.ihm.services.ProcessService", serviceName = "processService") public class ProcessServiceImpl implements ProcessService {
3/ J'ai configuré mon fichier de config SpringCode:
1
2
3
4 @Get @HttpResource(location="/operation/{id}") public List<Operation> getOperationsWithStatusForInhabitant(@WebParam(name="id") String inhabitantId) throws IhmException;
4/ Et mon fichier web.xmlCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <import resource="file:${org.intalio.tempo.configDirectory}/tempo-formmanager.xml"/> <import resource="classpath:META-INF/cxf/cxf.xml"/> <import resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> <jaxws:endpoint id="processService" implementor="xxxxxxxx.ihm.services.impl.ProcessServiceImpl" address="/services" bindingUri="http://apache.org/cxf/binding/http"> <jaxws:serviceFactory> <bean class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"> <property name="wrapped" value="false" /> </bean> </jaxws:serviceFactory> </jaxws:endpoint>
Est-ce qu'il y a d'autres étapes ?Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextClass</param-name> <param-value>org.intalio.tempo.web.SysPropWebApplicationContext</param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value>file:${org.intalio.tempo.configDirectory}/vdl-ihm.xml</param-value> </context-param> <servlet> <servlet-name>CXFServlet</servlet-name> <display-name>CXF Servlet</display-name> <servlet-class> org.apache.cxf.transport.servlet.CXFServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping>
Comment pourrais-je accéder à mon webservice REST ensuite ?
Voici la solution en ROUGE MAJUSCULES, à partir de ce que j'ai lu de la doc officielle
http://cwiki.apache.org/CXF20DOC/http-binding.html
1/ Ajouter l'annotation @Webservice à mon interface OK
Je l'ai également fait sur mon Impl mais je ne suis pas sûr qu'il faille le faire PAS BESOIN, TOUTES LES ANNOTATIONS SE FONT AU NIVEAU DE L'INTERFACE :Code:
1
2 @WebService public interface ProcessService {
2/ Dans mon interface, j'ai ajouté une annotation @Get, @HttpResource, @WebParam à la méthode que je souhaite exposer au webservice OKCode:
1
2
3
4
5 @WebService( endpointInterface = "xxxxxxxxx.ihm.services.ProcessService", serviceName = "processService") public class ProcessServiceImpl implements ProcessService {
3/ J'ai configuré mon fichier de config Spring L'ERREUR EST NOTEE EN ROUGECode:
1
2
3
4 @Get @HttpResource(location="/operation/{id}") public List<Operation> getOperationsWithStatusForInhabitant(@WebParam(name="id") String inhabitantId) throws IhmException;
4/ Et mon fichier web.xmlCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <import resource="file:${org.intalio.tempo.configDirectory}/tempo-formmanager.xml"/> <import resource="classpath:META-INF/cxf/cxf.xml"/> <import resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> <jaxws:endpoint id="processService" <--L'ERREUR EST ICI implementor="xxxxxxxx.ihm.services.impl.ProcessServiceImpl" address="/services" bindingUri="http://apache.org/cxf/binding/http"> <jaxws:serviceFactory> <bean class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"> <property name="wrapped" value="false" /> </bean> </jaxws:serviceFactory> </jaxws:endpoint>
En effet, l'erreur se situait au niveau de la déclaration de mon endpoint. Apparemment, et ce n'est documenté nulle part (sauf erreur), il ne doit pas porter le nom de mon interface.Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextClass</param-name> <param-value>org.intalio.tempo.web.SysPropWebApplicationContext</param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value>file:${org.intalio.tempo.configDirectory}/vdl-ihm.xml</param-value> </context-param> <servlet> <servlet-name>CXFServlet</servlet-name> <display-name>CXF Servlet</display-name> <servlet-class> org.apache.cxf.transport.servlet.CXFServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping>
Merci pour votre attention ! :yaisse2:
Bonjour,
j'ai vraiment besoin d'un cours pour un super extra débutant en web service pour implémenter rest ou autre api java pour exécuter des requetes xquery toutes pretes dans ma bases de données...
Merci merci beaucoup pour votre aide... j'en ai vraiment besoin...