mohamed mhadhbi
mohamed mhadhbi

Reputation: 11

Is it possible to integrate a web service in a spring + JSF project?

I need to establish a connexion between my android client and my spring + JSF server I need to send files from my android client and receive them in the server side for that, i tried to send the file directly to a bean which contains this function

      @Component
      @Scope("request")
      @Path("/file")
      public class RestWebService {
      @POST
      @Path("/upload")
      @Consumes(javax.ws.rs.core.MediaType.TEXT_PLAIN)
      public String uploadFile(
      @FormParam("file") InputStream uploadedInputStream,
      @FormParam("file") FormDataContentDisposition fileDetail,
      @QueryParam("inputFileName") String inputFileName) throws               FileNotFoundException{
      System.out.println("start upload");
       System.out.println(fileDetail.getFileName());
       return "";
}

and i added to my web.xml this lines:

       <display-name>Restful Web Application</display-name>
       <servlet>
       <servlet-name>jersey-serlvet</servlet-name>
       <servlet-     class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <init-param>
         <param-name>com.sun.jersey.config.property.packages</param-name>
         <param-value>com.test.WebService</param-value>
         </init-param>
        <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
        <servlet-name>jersey-serlvet</servlet-name>
        <url-pattern>/rest/*</url-pattern>
        </servlet-mapping>

but it seems that JSF block the connexion i want to know if it is possible to continue in this way or i must change this solution and in this case how ??

Upvotes: 0

Views: 255

Answers (1)

Armen Arzumanyan
Armen Arzumanyan

Reputation: 2053

JSF not blocking REST access url. You need just properly configuration. You can have a look JSF/REST project which is run under wildfly, you can access REST via url within JSF application, please have a look https://github.com/armdev/wildfly-jsf2.3-web

Upvotes: 1

Related Questions