Re: [Resteasy-users] Query of RestEasy Media Parsing

2013-01-09 Thread kishore panda
Hi,

I was successful doing it in the below two ways
 - Using ClientRequest and execute the method (POST). In this case Proxy is not 
used.
 - Change the interface
 
In both cases there was no need to override Executor.exeucte() for this issue.

Thank you for the support.

Thank you,
Malaya Kishore




--- On Tue, 1/8/13, Bill Burke bbu...@redhat.com wrote:

 From: Bill Burke bbu...@redhat.com
 Subject: Re: [Resteasy-users] Query of RestEasy Media Parsing
 To: resteasy-users@lists.sourceforge.net
 Date: Tuesday, January 8, 2013, 7:48 AM
 1) It is not a requirement to use a
 proxy
 2) No reason you can't have a different proxy for your
 client
 3) No reason you can't change your server-side class that
 implements 
 this interface to have a getXML() and getJSON() methods.
 
 IMO, I think what you all are doing is a hack.
 
 On 1/8/2013 2:02 AM, Dieter Cailliau wrote:
  I use a ClientInterceptor for that (the code also takes
 care of basic
  auth, timeouts and ssh-without-hostname-verification).
 
              
 ApacheHttpClient4Executor ex = new
 
 ApacheHttpClient4Executor(getBasicAuthClient(LOGIN,PASS,
  application/json, null, new
 
 SingleClientConnManager(getSSHBypassScheme(443)),timeoutMs));
               return
 ProxyFactory.create(XYZ.class, https://; + host +
  href, ex);
 
 
       public static DefaultHttpClient
 getBasicAuthClient(final String
  login, final String pass, final String acceptType,
 final String
  contentType, ClientConnectionManager ccm, int
 timeoutMs) throws
  NoSuchAlgorithmException, KeyManagementException {
           DefaultHttpClient c2
 = new DefaultHttpClient(ccm);
          
 c2.addRequestInterceptor(new HttpRequestInterceptor() {
               public
 void process(HttpRequest arg0, HttpContext arg1)
  throws HttpException, IOException {
                
   arg0.addHeader(Authorization,
  HTTPUtils.getBasicEncodedAuth(login, pass));
                
   arg0.addHeader(Accept, acceptType);
                
   if (contentType != null) {
                
      
 arg0.addHeader(ContentType,contentType);
                
   }
               }
           });
           HttpParams httpParams
 = c2.getParams();
          
 HttpConnectionParams.setConnectionTimeout(httpParams,
 timeoutMs);
          
 HttpConnectionParams.setSoTimeout(httpParams, timeoutMs);
          
 HttpConnectionParams.setSoReuseaddr(httpParams, true);
 
          
 c2.setParams(httpParams);
           return c2;
       }
 
       public static synchronized
 SchemeRegistry getSSHBypassScheme(int
  port) throws KeyManagementException,
 NoSuchAlgorithmException {
           if
 (schemeRegistry==null) {
              
 SSLSocketFactory sf = new SSLSocketFactory(getSSLContext(),
  SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER) {
                
   public java.net.Socket connectSocket(java.net.Socket
  arg0, java.net.InetSocketAddress arg1,
 java.net.InetSocketAddress arg2,
  HttpParams arg3) throws IOException
 ,java.net.UnknownHostException
  ,org.apache.http.conn.ConnectTimeoutException {
                
       int port = arg1.getPort();
                
       InetAddress addr =
 cache.get(arg1.getAddress());
                
       arg1 = new
 InetSocketAddress(addr,port);
                
       return super.connectSocket(arg0, arg1,
 arg2, arg3);
                
   };
               };
               Scheme
 httpsScheme = new Scheme(https, port, sf);
              
 schemeRegistry = new SchemeRegistry();
              
 schemeRegistry.register(httpsScheme);
           }
           return
 schemeRegistry;
       }
 
 
 
  2013/1/7 Bill Burke bbu...@redhat.com
 mailto:bbu...@redhat.com
 
      Why not just ditch using the
 proxy?  Or create a new different interface
      with the specs you want? 
 Overriding Exxecutor.exeucte() is a hack.
 
      On 1/7/2013 4:38 PM, kishore
 panda wrote:
       
        Hello,
       
        Query: How to ensure server
 sends JSON Media, when server is set
      with both Application_XML and
 Application_JSON Media Types (Produces
      annotation).
       
        I am executing a RESTEasy
 POC.
       
        I updated the server to accept
 and respond with both XML and JSON
      Media type.
       
          
    @POST
          
    @Path(/getData/)
          
    @Produces({MediaType.APPLICATION_XML,
      MediaType.APPLICATION_JSON})
          
    @Consumes({MediaType.APPLICATION_XML,
      MediaType.APPLICATION_JSON})
          
    public RestReqRes getData(Data request);
       
          In the client
 code, I have done this:
       
            
 this.clientService =
  
    ProxyFactory.create(clientService.class,
 baseURL,
              
                
    getExecutor());
       
       
           and Override
 execute() method in ApacheHttpClient4Executor.
       
          
    request.accept(MediaType.APPLICATION_JSON);
          
    request.body(application/json,
 request.getBody());
          
    return super.execute(request

Re: [Resteasy-users] Query of RestEasy Media Parsing

2013-01-08 Thread Bill Burke
1) It is not a requirement to use a proxy
2) No reason you can't have a different proxy for your client
3) No reason you can't change your server-side class that implements 
this interface to have a getXML() and getJSON() methods.

IMO, I think what you all are doing is a hack.

On 1/8/2013 2:02 AM, Dieter Cailliau wrote:
 I use a ClientInterceptor for that (the code also takes care of basic
 auth, timeouts and ssh-without-hostname-verification).

  ApacheHttpClient4Executor ex = new
 ApacheHttpClient4Executor(getBasicAuthClient(LOGIN,PASS,
 application/json, null, new
 SingleClientConnManager(getSSHBypassScheme(443)),timeoutMs));
  return ProxyFactory.create(XYZ.class, https://; + host +
 href, ex);


  public static DefaultHttpClient getBasicAuthClient(final String
 login, final String pass, final String acceptType, final String
 contentType, ClientConnectionManager ccm, int timeoutMs) throws
 NoSuchAlgorithmException, KeyManagementException {
  DefaultHttpClient c2 = new DefaultHttpClient(ccm);
  c2.addRequestInterceptor(new HttpRequestInterceptor() {
  public void process(HttpRequest arg0, HttpContext arg1)
 throws HttpException, IOException {
  arg0.addHeader(Authorization,
 HTTPUtils.getBasicEncodedAuth(login, pass));
  arg0.addHeader(Accept, acceptType);
  if (contentType != null) {
  arg0.addHeader(ContentType,contentType);
  }
  }
  });
  HttpParams httpParams = c2.getParams();
  HttpConnectionParams.setConnectionTimeout(httpParams, timeoutMs);
  HttpConnectionParams.setSoTimeout(httpParams, timeoutMs);
  HttpConnectionParams.setSoReuseaddr(httpParams, true);

  c2.setParams(httpParams);
  return c2;
  }

  public static synchronized SchemeRegistry getSSHBypassScheme(int
 port) throws KeyManagementException, NoSuchAlgorithmException {
  if (schemeRegistry==null) {
  SSLSocketFactory sf = new SSLSocketFactory(getSSLContext(),
 SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER) {
  public java.net.Socket connectSocket(java.net.Socket
 arg0, java.net.InetSocketAddress arg1, java.net.InetSocketAddress arg2,
 HttpParams arg3) throws IOException ,java.net.UnknownHostException
 ,org.apache.http.conn.ConnectTimeoutException {
  int port = arg1.getPort();
  InetAddress addr = cache.get(arg1.getAddress());
  arg1 = new InetSocketAddress(addr,port);
  return super.connectSocket(arg0, arg1, arg2, arg3);
  };
  };
  Scheme httpsScheme = new Scheme(https, port, sf);
  schemeRegistry = new SchemeRegistry();
  schemeRegistry.register(httpsScheme);
  }
  return schemeRegistry;
  }



 2013/1/7 Bill Burke bbu...@redhat.com mailto:bbu...@redhat.com

 Why not just ditch using the proxy?  Or create a new different interface
 with the specs you want?  Overriding Exxecutor.exeucte() is a hack.

 On 1/7/2013 4:38 PM, kishore panda wrote:
  
   Hello,
  
   Query: How to ensure server sends JSON Media, when server is set
 with both Application_XML and Application_JSON Media Types (Produces
 annotation).
  
   I am executing a RESTEasy POC.
  
   I updated the server to accept and respond with both XML and JSON
 Media type.
  
 @POST
 @Path(/getData/)
 @Produces({MediaType.APPLICATION_XML,
 MediaType.APPLICATION_JSON})
 @Consumes({MediaType.APPLICATION_XML,
 MediaType.APPLICATION_JSON})
 public RestReqRes getData(Data request);
  
 In the client code, I have done this:
  
this.clientService =
 ProxyFactory.create(clientService.class, baseURL,
 getExecutor());
  
  
  and Override execute() method in ApacheHttpClient4Executor.
  
 request.accept(MediaType.APPLICATION_JSON);
 request.body(application/json, request.getBody());
 return super.execute(request);
  
  
   When the client is used to POST the Request, like
 clientService.getData(new Data());
  
   I found the below
   The accept header in the Request is updated with application/xml.
  
   This happens due to
   
 org.jboss.resteasy.client.core.marshallers.ClientMarshallerFactory.createMarshaller()
  method, which calls org.jboss.resteasy.util.getConsumes() method.
  
   The getConsumes() method returns the consume.value()[0] media
 type which is  'application/xml' in this case.
  
  
   When request.accept(MediaType.APPLICATION_JSON); is executed the
 accept header in the request is updated with
   'application/xml, application/json'
  

[Resteasy-users] Query of RestEasy Media Parsing

2013-01-07 Thread kishore panda
Hello,

I am executing a RESTEasy POC. 

I updated the server to accept and respond with both XML and JSON Media type. 

@POST
@Path(/getData/)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public RestReqRes getData(Data request);

In the client code, I have done this:

   this.clientService = ProxyFactory.create(clientService.class, baseURL,
getExecutor());


 and Override execute() method
request.accept(MediaType.APPLICATION_JSON);
request.body(application/json, request.getBody());
return super.execute(request);


When the client is used to POST the Request, like
clientService.getData(

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


[Resteasy-users] Query of RestEasy Media Parsing

2013-01-07 Thread kishore panda
Hello,

I am executing a RESTEasy POC. 

I updated the server to accept and respond with both XML and JSON Media type. 

@POST
@Path(/getData/)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public RestReqRes getData(Data request);

In the client code, I have done this:

   this.clientService = ProxyFactory.create(clientService.class, baseURL,
getExecutor());


 and Override execute() method
request.accept(MediaType.APPLICATION_JSON);
request.body(application/json, request.getBody());
return super.execute(request);


When the client is used to POST the Request, like
clientService.getData(

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Query of RestEasy Media Parsing

2013-01-07 Thread kishore panda

Hello, 

Query: How to ensure server sends JSON Media, when server is set with both 
Application_XML and Application_JSON Media Types (Produces annotation).

I am executing a RESTEasy POC. 
 
I updated the server to accept and respond with both XML and JSON Media type. 

     @POST
     @Path(/getData/)
     @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
     @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
     public RestReqRes getData(Data request);
 
 In the client code, I have done this:
 
    this.clientService = ProxyFactory.create(clientService.class, baseURL,
     getExecutor());
 
 
  and Override execute() method in ApacheHttpClient4Executor.
    
 request.accept(MediaType.APPLICATION_JSON);
     request.body(application/json, request.getBody());
 return super.execute(request);
     
 
When the client is used to POST the Request, like
 clientService.getData(new Data());

I found the below 
The accept header in the Request is updated with application/xml. 

This happens due to  
org.jboss.resteasy.client.core.marshallers.ClientMarshallerFactory.createMarshaller()
 method, which calls org.jboss.resteasy.util.getConsumes() method.

The getConsumes() method returns the consume.value()[0] media type which is  
'application/xml' in this case.


When request.accept(MediaType.APPLICATION_JSON); is executed the accept header 
in the request is updated with
'application/xml, application/json'

Due to this the server always responds with xml format. 

Is there anyway I can override this so that the server responds JSON media as 
per the request.

Thank you,
Malaya Kishore

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Query of RestEasy Media Parsing

2013-01-07 Thread Bill Burke
Why not just ditch using the proxy?  Or create a new different interface 
with the specs you want?  Overriding Exxecutor.exeucte() is a hack.

On 1/7/2013 4:38 PM, kishore panda wrote:

 Hello,

 Query: How to ensure server sends JSON Media, when server is set with both 
 Application_XML and Application_JSON Media Types (Produces annotation).

 I am executing a RESTEasy POC.

 I updated the server to accept and respond with both XML and JSON Media type.

   @POST
   @Path(/getData/)
   @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
   @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
   public RestReqRes getData(Data request);

   In the client code, I have done this:

  this.clientService = ProxyFactory.create(clientService.class, baseURL,
   getExecutor());


and Override execute() method in ApacheHttpClient4Executor.

   request.accept(MediaType.APPLICATION_JSON);
   request.body(application/json, request.getBody());
   return super.execute(request);


 When the client is used to POST the Request, like
   clientService.getData(new Data());

 I found the below
 The accept header in the Request is updated with application/xml.

 This happens due to  
 org.jboss.resteasy.client.core.marshallers.ClientMarshallerFactory.createMarshaller()
  method, which calls org.jboss.resteasy.util.getConsumes() method.

 The getConsumes() method returns the consume.value()[0] media type which is  
 'application/xml' in this case.


 When request.accept(MediaType.APPLICATION_JSON); is executed the accept 
 header in the request is updated with
 'application/xml, application/json'

 Due to this the server always responds with xml format.

 Is there anyway I can override this so that the server responds JSON media as 
 per the request.

 Thank you,
 Malaya Kishore

 --
 Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
 MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
 with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
 MVPs and experts. SALE $99.99 this month only -- learn more at:
 http://p.sf.net/sfu/learnmore_122412
 ___
 Resteasy-users mailing list
 Resteasy-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/resteasy-users


-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Query of RestEasy Media Parsing

2013-01-07 Thread kishore panda
Hello,

Thank you for the response.

Why not just ditch using the proxy?
I am new to this. Could you please elaborate or provide any links where I can 
check this.

Or create a new different interface with the specs you want?  
The interface must support both XML and JSON. It should depend on the client on 
which Media transfer it uses.

Overriding Executor.exeucte() is a hack.
Thank you. I will avoid this.

Thank you,
Malaya Kishore

--- On Mon, 1/7/13, Bill Burke bbu...@redhat.com wrote:

 From: Bill Burke bbu...@redhat.com
 Subject: Re: [Resteasy-users] Query of RestEasy Media Parsing
 To: resteasy-users@lists.sourceforge.net
 Date: Monday, January 7, 2013, 3:59 PM
 Why not just ditch using the
 proxy?  Or create a new different interface 
 with the specs you want?  Overriding
 Exxecutor.exeucte() is a hack.
 
 On 1/7/2013 4:38 PM, kishore panda wrote:
 
  Hello,
 
  Query: How to ensure server sends JSON Media, when
 server is set with both Application_XML and Application_JSON
 Media Types (Produces annotation).
 
  I am executing a RESTEasy POC.
 
  I updated the server to accept and respond with both
 XML and JSON Media type.
 
        @POST
        @Path(/getData/)
    
    @Produces({MediaType.APPLICATION_XML,
 MediaType.APPLICATION_JSON})
    
    @Consumes({MediaType.APPLICATION_XML,
 MediaType.APPLICATION_JSON})
        public RestReqRes
 getData(Data request);
 
    In the client code, I have done this:
 
       this.clientService =
 ProxyFactory.create(clientService.class, baseURL,
                
        
    getExecutor());
 
 
     and Override execute() method in
 ApacheHttpClient4Executor.
 
    
    request.accept(MediaType.APPLICATION_JSON);
    
    request.body(application/json,
 request.getBody());
        return
 super.execute(request);
 
 
  When the client is used to POST the Request, like
    clientService.getData(new Data());
 
  I found the below
  The accept header in the Request is updated with
 application/xml.
 
  This happens due to 
 org.jboss.resteasy.client.core.marshallers.ClientMarshallerFactory.createMarshaller()
 method, which calls org.jboss.resteasy.util.getConsumes()
 method.
 
  The getConsumes() method returns the consume.value()[0]
 media type which is  'application/xml' in this case.
 
 
  When request.accept(MediaType.APPLICATION_JSON); is
 executed the accept header in the request is updated with
  'application/xml, application/json'
 
  Due to this the server always responds with xml
 format.
 
  Is there anyway I can override this so that the server
 responds JSON media as per the request.
 
  Thank you,
  Malaya Kishore
 
 
 --
  Master Visual Studio, SharePoint, SQL, ASP.NET, C#
 2012, HTML5, CSS,
  MVC, Windows 8 Apps, JavaScript and much more. Keep
 your skills current
  with LearnDevNow - 3,200 step-by-step video tutorials
 by Microsoft
  MVPs and experts. SALE $99.99 this month only -- learn
 more at:
  http://p.sf.net/sfu/learnmore_122412
  ___
  Resteasy-users mailing list
  Resteasy-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/resteasy-users
 
 
 -- 
 Bill Burke
 JBoss, a division of Red Hat
 http://bill.burkecentral.com
 
 --
 Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012,
 HTML5, CSS,
 MVC, Windows 8 Apps, JavaScript and much more. Keep your
 skills current
 with LearnDevNow - 3,200 step-by-step video tutorials by
 Microsoft
 MVPs and experts. SALE $99.99 this month only -- learn more
 at:
 http://p.sf.net/sfu/learnmore_122412
 ___
 Resteasy-users mailing list
 Resteasy-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/resteasy-users
 

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Query of RestEasy Media Parsing

2013-01-07 Thread Dieter Cailliau
I use a ClientInterceptor for that (the code also takes care of basic auth,
timeouts and ssh-without-hostname-verification).

ApacheHttpClient4Executor ex = new
ApacheHttpClient4Executor(getBasicAuthClient(LOGIN,PASS,
application/json, null, new
SingleClientConnManager(getSSHBypassScheme(443)),timeoutMs));
return ProxyFactory.create(XYZ.class, https://; + host + href,
ex);


public static DefaultHttpClient getBasicAuthClient(final String login,
final String pass, final String acceptType, final String contentType,
ClientConnectionManager ccm, int timeoutMs) throws
NoSuchAlgorithmException, KeyManagementException {
DefaultHttpClient c2 = new DefaultHttpClient(ccm);
c2.addRequestInterceptor(new HttpRequestInterceptor() {
public void process(HttpRequest arg0, HttpContext arg1) throws
HttpException, IOException {
arg0.addHeader(Authorization,
HTTPUtils.getBasicEncodedAuth(login, pass));
arg0.addHeader(Accept, acceptType);
if (contentType != null) {
arg0.addHeader(ContentType,contentType);
}
}
});
HttpParams httpParams = c2.getParams();
HttpConnectionParams.setConnectionTimeout(httpParams, timeoutMs);
HttpConnectionParams.setSoTimeout(httpParams, timeoutMs);
HttpConnectionParams.setSoReuseaddr(httpParams, true);

c2.setParams(httpParams);
return c2;
}

public static synchronized SchemeRegistry getSSHBypassScheme(int port)
throws KeyManagementException, NoSuchAlgorithmException {
if (schemeRegistry==null) {
SSLSocketFactory sf = new SSLSocketFactory(getSSLContext(),
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER) {
public java.net.Socket connectSocket(java.net.Socket arg0,
java.net.InetSocketAddress arg1, java.net.InetSocketAddress arg2,
HttpParams arg3) throws IOException ,java.net.UnknownHostException
,org.apache.http.conn.ConnectTimeoutException {
int port = arg1.getPort();
InetAddress addr = cache.get(arg1.getAddress());
arg1 = new InetSocketAddress(addr,port);
return super.connectSocket(arg0, arg1, arg2, arg3);
};
};
Scheme httpsScheme = new Scheme(https, port, sf);
schemeRegistry = new SchemeRegistry();
schemeRegistry.register(httpsScheme);
}
return schemeRegistry;
}



2013/1/7 Bill Burke bbu...@redhat.com

 Why not just ditch using the proxy?  Or create a new different interface
 with the specs you want?  Overriding Exxecutor.exeucte() is a hack.

 On 1/7/2013 4:38 PM, kishore panda wrote:
 
  Hello,
 
  Query: How to ensure server sends JSON Media, when server is set with
 both Application_XML and Application_JSON Media Types (Produces annotation).
 
  I am executing a RESTEasy POC.
 
  I updated the server to accept and respond with both XML and JSON Media
 type.
 
@POST
@Path(/getData/)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public RestReqRes getData(Data request);
 
In the client code, I have done this:
 
   this.clientService = ProxyFactory.create(clientService.class,
 baseURL,
getExecutor());
 
 
 and Override execute() method in ApacheHttpClient4Executor.
 
request.accept(MediaType.APPLICATION_JSON);
request.body(application/json, request.getBody());
return super.execute(request);
 
 
  When the client is used to POST the Request, like
clientService.getData(new Data());
 
  I found the below
  The accept header in the Request is updated with application/xml.
 
  This happens due to
  
 org.jboss.resteasy.client.core.marshallers.ClientMarshallerFactory.createMarshaller()
 method, which calls org.jboss.resteasy.util.getConsumes() method.
 
  The getConsumes() method returns the consume.value()[0] media type which
 is  'application/xml' in this case.
 
 
  When request.accept(MediaType.APPLICATION_JSON); is executed the accept
 header in the request is updated with
  'application/xml, application/json'
 
  Due to this the server always responds with xml format.
 
  Is there anyway I can override this so that the server responds JSON
 media as per the request.
 
  Thank you,
  Malaya Kishore
 
 
 --
  Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
  MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
  with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
  MVPs and experts. SALE $99.99 this month only -- learn more at:
  http://p.sf.net/sfu/learnmore_122412
  ___
  Resteasy-users mailing list