cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Kulp (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CXF-2978) CLONE -Return Type List gets null on client if an empty list is returned
Date Wed, 08 Sep 2010 17:23:38 GMT

    [ https://issues.apache.org/jira/browse/CXF-2978?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12907325#action_12907325
] 

Daniel Kulp commented on CXF-2978:
----------------------------------


Well, for RETURN values (not parameters), you can add an @XmlElementWrapper(nillable = true,
name = "return") directly to the List<Customer> findCustomer(); method of the CustomerService
class and that will work with CXF 2.2.10.   Doing so is going outside the JAXWS spec though
as the spec doesn't provide for the XmlElementWrapper annotation to be added to the WebMethods.
    It also ONLY works for return values as XmElementWrapper is not allowed on method params.
  Just method and field locations.  

But for the most part, according to spec, in this case, null is the correct return.   One
the wire, there would not be any difference if you return an empty list or null so, according
to spec, it's mapped to null by default.



> CLONE -Return Type List gets null on client if an empty list is returned
> ------------------------------------------------------------------------
>
>                 Key: CXF-2978
>                 URL: https://issues.apache.org/jira/browse/CXF-2978
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.1.8, 2.2.7, 2.2.9, 2.2.10
>         Environment: JSE 1.5 on Win XP
>            Reporter: Staffan Forsell
>            Assignee: Daniel Kulp
>            Priority: Critical
>         Attachments: EmptyListExample-2.2.10.tar.gz
>
>
> If you have a function that returns an empty list  the result will be null on client.
Even If add a Responsewrapper to the interface it doesn't work. If have attached a little
test project / program:
> Interface:
> @WebService(targetNamespace = "http://cxf.apache.org/demo/CustomerService/1/", name =
"CustomerService")
> @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL)
> public interface CustomerService {
> 	@WebMethod(action = "findCustomer", operationName = "findCustomer")
> 	public @WebResult(name = "customerList")
> 	List<Customer> findCustomer();
> 	
> 	
> 	@WebMethod(action = "findCustomer2", operationName = "findCustomer2")
> 	@ResponseWrapper(className="demo.service.CustomerListResponse")
> 	public @WebResult(name = "customerList")
> 	List<Customer> findCustomer2();
> }
> The Implementation:
> @WebService(name = "CustomerService", serviceName = "CustomerService", targetNamespace
= "http://cxf.apache.org/demo/CustomerService/1/", endpointInterface = "demo.service.CustomerService")
> public class CustomerServiceImpl implements CustomerService {
> 	public List<Customer> findCustomer() {
> 		// very stupid method
> 		return new ArrayList<Customer>();
> 	}
> 	public List<Customer> findCustomer2() {
> 		// another very stupid method
> 		return new ArrayList<Customer>();
> 	}
> }
> And this is the main programm:
> public static void main(String args[]) throws Exception {
> 		new Server();
> 		System.out.println("Server ready...");
> 		// Now Call the Service
> 		JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> 		factory.getInInterceptors().add(new LoggingInInterceptor());
> 		factory.getOutInterceptors().add(new LoggingOutInterceptor());
> 		factory.setServiceClass(CustomerService.class);
> 		factory.setAddress("http://localhost:9000/CustomerService");
> 		CustomerService client = (CustomerService) factory.create();
> 		System.out.println("call findCustomer()");
> 		List<Customer> result = client.findCustomer();
> 		if (result != null)
> 			System.out.println("Listsize: " + result.size());
> 		else
> 			System.out.println("List is null: " + result);
> 		System.out.println("call findCustomer2()");
> 		result = client.findCustomer2();
> 		if (result != null) 
>                          System.out.println("Listsize: " + result.size());
> 		else
> 			System.out.println("List is null: " + result);
> 		System.out.println("Server exiting");
>                 System.exit(0);
> 	}
> This will print the following output:
> Server ready...
> call findCustomer()
> 20.01.2010 07:49:45 org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback
onClose
> INFO: Outbound Message
> ---------------------------
> ID: 1
> Address: http://localhost:9000/CustomerService
> Encoding: UTF-8
> Content-Type: text/xml
> Headers: {SOAPAction=["findCustomer"], Accept=[*/*]}
> Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:findCustomer
xmlns:ns2="http://cxf.apache.org/demo/CustomerService/1/"/></soap:Body></soap:Envelope>
> --------------------------------------
> 20.01.2010 07:49:45 org.apache.cxf.interceptor.LoggingInInterceptor logging
> INFO: Inbound Message
> ----------------------------
> ID: 1
> Encoding: UTF-8
> Content-Type: text/xml; charset=utf-8
> Headers: {Content-Length=[194], Server=[Jetty(6.1.21)], content-type=[text/xml; charset=utf-8]}
> Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:findCustomerResponse
xmlns:ns2="http://cxf.apache.org/demo/CustomerService/1/"/></soap:Body></soap:Envelope>
> --------------------------------------
> List is null: null
> call findCustomer2()
> 20.01.2010 07:49:45 org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback
onClose
> INFO: Outbound Message
> ---------------------------
> ID: 2
> Address: http://localhost:9000/CustomerService
> Encoding: UTF-8
> Content-Type: text/xml
> Headers: {SOAPAction=["findCustomer2"], Accept=[*/*]}
> Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:findCustomer2
xmlns:ns2="http://cxf.apache.org/demo/CustomerService/1/"/></soap:Body></soap:Envelope>
> --------------------------------------
> 20.01.2010 07:49:45 org.apache.cxf.interceptor.LoggingInInterceptor logging
> INFO: Inbound Message
> ----------------------------
> ID: 2
> Encoding: UTF-8
> Content-Type: text/xml; charset=utf-8
> Headers: {Content-Length=[300], Server=[Jetty(6.1.21)], content-type=[text/xml; charset=utf-8]}
> Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:findCustomer2Response
xmlns:ns2="http://cxf.apache.org/demo/CustomerService/1/"><return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nil="true"/></ns2:findCustomer2Response></soap:Body></soap:Envelope>
> --------------------------------------
> List is null: null
> Server exiting

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


Mime
View raw message