camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Müller <christian.muel...@gmail.com>
Subject Re: Exception in restful web service
Date Thu, 07 Feb 2013 22:26:07 GMT
The first think you should mention is the version you are using. Check out
http://camel.apache.org/support.html
If you are using Camel 2.10+, you don't need the imports for
"cxf-servlet.xml" or "cxf-extension-soap.xml". And by the way, soap !=
jaxrs...
And why you don't return a simple "Hello" in your "sayXMLHello" method? I
hope you don't try to put a XML into XML, you do?
Any be the way, you should close your streams in a finally block...

Best,
Christian

On Thu, Feb 7, 2013 at 1:13 PM, Richa <rsinha2889@gmail.com> wrote:

> My server class looks like this:
>
>
> import java.io.BufferedReader;
> import java.io.DataInputStream;
> import java.io.FileInputStream;
> import java.io.InputStreamReader;
>
> import javax.ws.rs.Consumes;
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
>
> @Path("/hello")
> public class Hello {
>
>         // This method is called if XML is request
>         @GET
>         @Path("/xmlHello")
>         @Produces ( "application/xml" )
>         public String sayXMLHello() {
>                 System.out.println("in");
>                 String s = "";
>                 try {
>                         // Open the file that is the first
>                         // command line parameter
>                         FileInputStream fstream = new FileInputStream(
>                                         "D:\\Testing\\test.xml");
>                         // Get the object of DataInputStream
>                         DataInputStream in = new DataInputStream(fstream);
>                         BufferedReader br = new BufferedReader(new
> InputStreamReader(in));
>                         String strLine;
>                         // Read File Line By Line
>                         while ((strLine = br.readLine()) != null) {
>                                 // Print the content on the console
>                                 s += strLine;
>                         }
>                         // Close the input stream
>                         in.close();
>                 } catch (Exception e) {// Catch exception if any
>                         System.err.println("Error: " + e.getMessage());
>                 }
>                 System.out.println("File read");
>                 return s;
>         }
>
> }
>
> and this is the contents of my cxf.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:jaxrs="http://cxf.apache.org/jaxrs"
>       xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
>
>   <import resource="classpath:META-INF/cxf/cxf.xml" />
>   <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
>   <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
>   <jaxrs:server id="restService" address="http://localhost:8080/RESTApp"
> serviceClass="com.amadeus.Server.Hello" />
>
>   <jaxrs:client id="restClient" serviceClass="com.amadeus.Client.Test" />
>
> </beans>
>
>
> Please tell me if I am doing something wrong in the configuration.
> Thank you
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Exception-in-restful-web-service-tp5727019p5727107.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message