You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Gabo Manuel (JIRA)" <ji...@apache.org> on 2008/10/22 13:02:44 UTC

[jira] Created: (CXF-1882) JAX-RS can't unmarshall request body if the corresponding parameter is annotated with non-JAX-RS annotation

JAX-RS can't unmarshall request body if the corresponding parameter is annotated with non-JAX-RS annotation
-----------------------------------------------------------------------------------------------------------

                 Key: CXF-1882
                 URL: https://issues.apache.org/jira/browse/CXF-1882
             Project: CXF
          Issue Type: Bug
          Components: JAX-WS Runtime, JAXB Databinding, REST
    Affects Versions: 2.1.2
         Environment: windows XP
apache-tomcat-6.0.13
jdk1.6.0_02
            Reporter: Gabo Manuel


I have a java-first service. The goal is to have a single service implementation that can be accessed via SOAP or as ReST service. I am using the JAX-WS annotations to have a more descriptive WSDL. I am using the JAX-RS annotations as defined in: http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html . Below is a trimmed down version of the code:

//AccountService.java
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.ws.rs.ConsumeMime;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;

@WebService(serviceName="AccountService")
@ConsumeMime("text/xml") 
public class AccountService {
	@PUT
	@Path("/Account")
	@WebMethod
	public long insert(
			@WebParam(name="account")
			Account account
			) {
		logger.info("insert Received: " + account);
		return 0;
	}
}

//Account.java
import javax.ws.rs.Path;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlRootElement(name="Account")
@XmlType(name="Account")
@XmlAccessorType(XmlAccessType.PROPERTY)
public class Account {
	private String accountID = "";
	public String getAccountID() {
		return accountID;
	}

	public void setAccountID(String accountID) {
		this.accountID = accountID;
	}
}
	
//beans.xml
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jaxws="http://cxf.apache.org/jaxws"
      xmlns:soap="http://cxf.apache.org/bindings/soap"
	  xmlns:sec="http://cxf.apache.org/configuration/security"
	  xmlns:jaxrs="http://cxf.apache.org/jaxrs"
      xsi:schemaLocation="
		http://www.springframework.org/schema/beans 
	    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
	    http://cxf.apache.org/bindings/soap 
	    http://cxf.apache.org/schemas/configuration/soap.xsd
	    http://cxf.apache.org/core
	    http://cxf.apache.org/schemas/core.xsd
		http://cxf.apache.org/jaxrs
		http://cxf.apache.org/schemas/jaxrs.xsd
	    http://cxf.apache.org/jaxws 
	    http://cxf.apache.org/schemas/jaxws.xsd 
	    http://cxf.apache.org/configuration/security 
	    http://cxf.apache.org/schemas/configuration/security.xsd
	    http://cxf.apache.org/transports/http/configuration
	    http://cxf.apache.org/schemas/configuration/http-conf.xsd
	    http://cxf.apache.org/transports/http-jetty/configuration
	    http://cxf.apache.org/schemas/configuration/http-jetty.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" />
    <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
    <import resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml"/>
	<import resource="classpath:META-INF/cxf/cxf-extension-xml.xml"/>
	
	<jaxrs:server id="accountRestService" address="/rest/Accounts">
		<jaxrs:serviceBeans>
			<ref bean="accountServiceClass" />
		</jaxrs:serviceBeans>
	</jaxrs:server>

	<bean id="accountServiceClass" class="AccountService" />

    <jaxws:endpoint 
        id="accountSoapService" 
        address="/soap/Accounts"
        implementor="#accountServiceClass"
        >
    </jaxws:endpoint>
</beans>

I have already discussed this with Sergey of CXF support team (http://www.nabble.com/-JAX-WS--JAX-RS--tt20007600.html). The issue seem to be not present if the parameter is not annotated by JAX-WS. Below is a snippet of his findings:

<quote>
I think I might know what might be happening - JAXRS runtime does not recognize the Account as being a standalone method parameter as it's annotated with a JAXWS annotation. On other words, in JAX-RS, providers(by default) are used only when unmarshalling parameters not annotated with JAX-RS annotations, for ex

void foo(@PathParam("id") String id, Account acc);

here the Account will be unmarshalled as expected but because you have

void foo(@WebParam(name="account") Account account);

the runtime mistakenly ignores it.... 
</quote>

Please advise if you need more information.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (CXF-1882) JAX-RS can't unmarshall request body if the corresponding parameter is annotated with non-JAX-RS annotation

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-1882?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sergey Beryozkin reassigned CXF-1882:
-------------------------------------

    Assignee: Sergey Beryozkin

> JAX-RS can't unmarshall request body if the corresponding parameter is annotated with non-JAX-RS annotation
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-1882
>                 URL: https://issues.apache.org/jira/browse/CXF-1882
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-WS Runtime, JAXB Databinding, REST
>    Affects Versions: 2.1.2
>         Environment: windows XP
> apache-tomcat-6.0.13
> jdk1.6.0_02
>            Reporter: Gabo Manuel
>            Assignee: Sergey Beryozkin
>             Fix For: 2.1.4, 2.2
>
>
> I have a java-first service. The goal is to have a single service implementation that can be accessed via SOAP or as ReST service. I am using the JAX-WS annotations to have a more descriptive WSDL. I am using the JAX-RS annotations as defined in: http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html . Below is a trimmed down version of the code:
> //AccountService.java
> import javax.jws.WebMethod;
> import javax.jws.WebParam;
> import javax.jws.WebService;
> import javax.ws.rs.ConsumeMime;
> import javax.ws.rs.PUT;
> import javax.ws.rs.Path;
> @WebService(serviceName="AccountService")
> @ConsumeMime("text/xml") 
> public class AccountService {
> 	@PUT
> 	@Path("/Account")
> 	@WebMethod
> 	public long insert(
> 			@WebParam(name="account")
> 			Account account
> 			) {
> 		logger.info("insert Received: " + account);
> 		return 0;
> 	}
> }
> //Account.java
> import javax.ws.rs.Path;
> import javax.xml.bind.annotation.XmlAccessType;
> import javax.xml.bind.annotation.XmlAccessorType;
> import javax.xml.bind.annotation.XmlRootElement;
> import javax.xml.bind.annotation.XmlType;
> @XmlRootElement(name="Account")
> @XmlType(name="Account")
> @XmlAccessorType(XmlAccessType.PROPERTY)
> public class Account {
> 	private String accountID = "";
> 	public String getAccountID() {
> 		return accountID;
> 	}
> 	public void setAccountID(String accountID) {
> 		this.accountID = accountID;
> 	}
> }
> 	
> //beans.xml
> <beans xmlns="http://www.springframework.org/schema/beans"
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xmlns:jaxws="http://cxf.apache.org/jaxws"
>       xmlns:soap="http://cxf.apache.org/bindings/soap"
> 	  xmlns:sec="http://cxf.apache.org/configuration/security"
> 	  xmlns:jaxrs="http://cxf.apache.org/jaxrs"
>       xsi:schemaLocation="
> 		http://www.springframework.org/schema/beans 
> 	    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
> 	    http://cxf.apache.org/bindings/soap 
> 	    http://cxf.apache.org/schemas/configuration/soap.xsd
> 	    http://cxf.apache.org/core
> 	    http://cxf.apache.org/schemas/core.xsd
> 		http://cxf.apache.org/jaxrs
> 		http://cxf.apache.org/schemas/jaxrs.xsd
> 	    http://cxf.apache.org/jaxws 
> 	    http://cxf.apache.org/schemas/jaxws.xsd 
> 	    http://cxf.apache.org/configuration/security 
> 	    http://cxf.apache.org/schemas/configuration/security.xsd
> 	    http://cxf.apache.org/transports/http/configuration
> 	    http://cxf.apache.org/schemas/configuration/http-conf.xsd
> 	    http://cxf.apache.org/transports/http-jetty/configuration
> 	    http://cxf.apache.org/schemas/configuration/http-jetty.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" />
>     <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
>     <import resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml"/>
> 	<import resource="classpath:META-INF/cxf/cxf-extension-xml.xml"/>
> 	
> 	<jaxrs:server id="accountRestService" address="/rest/Accounts">
> 		<jaxrs:serviceBeans>
> 			<ref bean="accountServiceClass" />
> 		</jaxrs:serviceBeans>
> 	</jaxrs:server>
> 	<bean id="accountServiceClass" class="AccountService" />
>     <jaxws:endpoint 
>         id="accountSoapService" 
>         address="/soap/Accounts"
>         implementor="#accountServiceClass"
>         >
>     </jaxws:endpoint>
> </beans>
> I have already discussed this with Sergey of CXF support team (http://www.nabble.com/-JAX-WS--JAX-RS--tt20007600.html). The issue seem to be not present if the parameter is not annotated by JAX-WS. Below is a snippet of his findings:
> <quote>
> I think I might know what might be happening - JAXRS runtime does not recognize the Account as being a standalone method parameter as it's annotated with a JAXWS annotation. On other words, in JAX-RS, providers(by default) are used only when unmarshalling parameters not annotated with JAX-RS annotations, for ex
> void foo(@PathParam("id") String id, Account acc);
> here the Account will be unmarshalled as expected but because you have
> void foo(@WebParam(name="account") Account account);
> the runtime mistakenly ignores it.... 
> </quote>
> Please advise if you need more information.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (CXF-1882) JAX-RS can't unmarshall request body if the corresponding parameter is annotated with non-JAX-RS annotation

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-1882?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sergey Beryozkin resolved CXF-1882.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.2
                   2.1.4

> JAX-RS can't unmarshall request body if the corresponding parameter is annotated with non-JAX-RS annotation
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-1882
>                 URL: https://issues.apache.org/jira/browse/CXF-1882
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-WS Runtime, JAXB Databinding, REST
>    Affects Versions: 2.1.2
>         Environment: windows XP
> apache-tomcat-6.0.13
> jdk1.6.0_02
>            Reporter: Gabo Manuel
>            Assignee: Sergey Beryozkin
>             Fix For: 2.1.4, 2.2
>
>
> I have a java-first service. The goal is to have a single service implementation that can be accessed via SOAP or as ReST service. I am using the JAX-WS annotations to have a more descriptive WSDL. I am using the JAX-RS annotations as defined in: http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html . Below is a trimmed down version of the code:
> //AccountService.java
> import javax.jws.WebMethod;
> import javax.jws.WebParam;
> import javax.jws.WebService;
> import javax.ws.rs.ConsumeMime;
> import javax.ws.rs.PUT;
> import javax.ws.rs.Path;
> @WebService(serviceName="AccountService")
> @ConsumeMime("text/xml") 
> public class AccountService {
> 	@PUT
> 	@Path("/Account")
> 	@WebMethod
> 	public long insert(
> 			@WebParam(name="account")
> 			Account account
> 			) {
> 		logger.info("insert Received: " + account);
> 		return 0;
> 	}
> }
> //Account.java
> import javax.ws.rs.Path;
> import javax.xml.bind.annotation.XmlAccessType;
> import javax.xml.bind.annotation.XmlAccessorType;
> import javax.xml.bind.annotation.XmlRootElement;
> import javax.xml.bind.annotation.XmlType;
> @XmlRootElement(name="Account")
> @XmlType(name="Account")
> @XmlAccessorType(XmlAccessType.PROPERTY)
> public class Account {
> 	private String accountID = "";
> 	public String getAccountID() {
> 		return accountID;
> 	}
> 	public void setAccountID(String accountID) {
> 		this.accountID = accountID;
> 	}
> }
> 	
> //beans.xml
> <beans xmlns="http://www.springframework.org/schema/beans"
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xmlns:jaxws="http://cxf.apache.org/jaxws"
>       xmlns:soap="http://cxf.apache.org/bindings/soap"
> 	  xmlns:sec="http://cxf.apache.org/configuration/security"
> 	  xmlns:jaxrs="http://cxf.apache.org/jaxrs"
>       xsi:schemaLocation="
> 		http://www.springframework.org/schema/beans 
> 	    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
> 	    http://cxf.apache.org/bindings/soap 
> 	    http://cxf.apache.org/schemas/configuration/soap.xsd
> 	    http://cxf.apache.org/core
> 	    http://cxf.apache.org/schemas/core.xsd
> 		http://cxf.apache.org/jaxrs
> 		http://cxf.apache.org/schemas/jaxrs.xsd
> 	    http://cxf.apache.org/jaxws 
> 	    http://cxf.apache.org/schemas/jaxws.xsd 
> 	    http://cxf.apache.org/configuration/security 
> 	    http://cxf.apache.org/schemas/configuration/security.xsd
> 	    http://cxf.apache.org/transports/http/configuration
> 	    http://cxf.apache.org/schemas/configuration/http-conf.xsd
> 	    http://cxf.apache.org/transports/http-jetty/configuration
> 	    http://cxf.apache.org/schemas/configuration/http-jetty.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" />
>     <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
>     <import resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml"/>
> 	<import resource="classpath:META-INF/cxf/cxf-extension-xml.xml"/>
> 	
> 	<jaxrs:server id="accountRestService" address="/rest/Accounts">
> 		<jaxrs:serviceBeans>
> 			<ref bean="accountServiceClass" />
> 		</jaxrs:serviceBeans>
> 	</jaxrs:server>
> 	<bean id="accountServiceClass" class="AccountService" />
>     <jaxws:endpoint 
>         id="accountSoapService" 
>         address="/soap/Accounts"
>         implementor="#accountServiceClass"
>         >
>     </jaxws:endpoint>
> </beans>
> I have already discussed this with Sergey of CXF support team (http://www.nabble.com/-JAX-WS--JAX-RS--tt20007600.html). The issue seem to be not present if the parameter is not annotated by JAX-WS. Below is a snippet of his findings:
> <quote>
> I think I might know what might be happening - JAXRS runtime does not recognize the Account as being a standalone method parameter as it's annotated with a JAXWS annotation. On other words, in JAX-RS, providers(by default) are used only when unmarshalling parameters not annotated with JAX-RS annotations, for ex
> void foo(@PathParam("id") String id, Account acc);
> here the Account will be unmarshalled as expected but because you have
> void foo(@WebParam(name="account") Account account);
> the runtime mistakenly ignores it.... 
> </quote>
> Please advise if you need more information.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.