cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sambit Dikshit (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CXF-5288) BeanParam does not work as expected
Date Wed, 18 Sep 2013 11:10:52 GMT
Sambit Dikshit created CXF-5288:
-----------------------------------

             Summary: BeanParam does not work as expected 
                 Key: CXF-5288
                 URL: https://issues.apache.org/jira/browse/CXF-5288
             Project: CXF
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.7.3
            Reporter: Sambit Dikshit


Hi,
 I'm using CXF 2.7.3 version. Our resource API look like below. 

1. 
@POST
@Path("/books-param-bean")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
Book addBookWithParamBeans(@BeanParam BookHeaderBean headerBean,@QueryParam("") BookQueryBean
queryBean,Book book) throws ServiceException;

2. 
@POST
@Path("/books-header-bean")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })

@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
Book addBookWithHeaderBean(@BeanParam BookHeaderBean headerBean,Book req) throws ServiceException;

3. 
@POST
@Path("/books-query-bean")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
	Book addBookWithQueryBean(@QueryParam("") BookQueryBean queryBean,Book req) throws ServiceException;

Then i'm trying to consume the API using proxy based approach like below. 

Book req = new Book();
Book b = new Book("CXF Action 127", 127L);
b.setChapters(null);
req.setPayload(b);
			
BookHeaderBean headerBean = new BookHeaderBean();
headerBean.setHeaderName("CXF-127-Book-From-Header");
headerBean.setTestHeader("test");

// get handle to BookStore proxy using WebClient, i'm skipping that code here. 
Book response = bookStoreProxy.addBookWithHeaderBean(headerBean,req);


The header bean class look like below. 

public class BookHeaderBean implements Serializable {
	private static final long serialVersionUID = 1L;	
	@HeaderParam("NAME")
	private String headerName;
        @HeaderParam("TEST")
	private String testHeader;
	
	public String getHeaderName() {
		return headerName;
	}
	public void setHeaderName(String headerName) {
		this.headerName = headerName;
	}
	public String getTestHeader() {
		return testHeader;
	}
	public void setTestHeader(String testHeader) {
		this.testHeader = testHeader;
	}
}


public class BookQueryBean implements Serializable {
     private String name;
     private long id;
     private String status;

     public BookQueryBean(String name, long id) {
		this.name = name;
		this.id = id;
     }
     public void setName(String n) {
		name = n;
	}

	public String getName() {
		return name;
	}
	public void setId(long i) {
		id = i;
	}

	public long getId() {
		return id;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
}


Now when we try the proxy based client to call the methods which take header bean and query
beans, only the query bean method is working. The header beans does not work. Basically the
@BeanParam defined beans are not working through client side proxy. However when we directly
hit the URL from a rest browser and construct the http header and query strings etc, it does
work. It means the un-marshaling from header parameters to beans is happening at server side.
where as marshaling from bean to header params is not happening at client side proxy impl.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message