You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by cmoulliard <cm...@gmail.com> on 2008/10/08 12:32:36 UTC

ClientProxyFactoryBean return null !!!

Hi,

I have a strange problem when I use ClientProxyFactoryBean. I have created a
Cxf project (using cxf 2.1.2) and generated code from my WSDL file using
wsdl2java generator.

In the following unit test, the result of the web service call is NULL. 

	private static String ADDRESS = "http://localhost:9000/unittesttrack";
	
	@BeforeClass
    public static void startServer() throws Exception {
        // We need to start a server that exposes or webservice during the
unit testing
        // We use jaxws to do this pretty simple
    	TrackerServiceImpl server = new TrackerServiceImpl();
        Endpoint.publish(ADDRESS, server);

    }
	
	@Test
	public void serverStarted() throws Exception {
    	// Start server
    	this.startServer();
	}
	

	@Test
	public void shouldGenerateWsdl() throws Exception {
		URL url = new URL(ADDRESS + "?wsdl");
		URLConnection connection = url.openConnection();
		Assert.assertNotNull(connection.getContent());
		showResponse(connection);
	}

	@Test
	public void shouldHaveParcelViaWebService() throws Exception {
	   	XMLGregorianCalendar calendar =
DatatypeFactory.newInstance().newXMLGregorianCalendar( new
GregorianCalendar());
    	calendar.setDay(7);
    	calendar.setMonth(10);
    	calendar.setYear(2008);
    	
    	// Create web service client
    	createWebServiceClient();
		
    	TrackParcelEndpoint client = createWebServiceClient();
		InputTrackParcel parcel = new InputTrackParcel();
		parcel.setName("chm");
		parcel.setDestination("Brussels");
		parcel.setOrigin("Florennes");
		parcel.setDeliveryDate(calendar);
		
		OutputTrackParcel result = client.PostParcel(parcel);
		Log.info("Result : " + result.getReference()); <<<<<  NULL POINTER
EXCEPTION IS GENERATED HERE
		Assert.assertNotNull(result);
	}

	private TrackParcelEndpoint createWebServiceClient() {
      	
		ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
		factory.setServiceClass(TrackParcelEndpoint.class);
		factory.setAddress(ADDRESS);
		TrackParcelEndpoint client = (TrackParcelEndpoint) factory.create();
		return client;
	}

Surprisingly, if I try to connect to the server using the SOAPUI client, my
SOAPUI client receives a reply from the service.

How can I solve/debug my problem ?

Charles Moulliard

-----
Enterprise Architect

Xpectis
12, route d'Esch
L-1470 Luxembourg

Phone +352 25 10 70 470
Mobile +352 621 45 36 22

e-mail : cmoulliard@xpectis.com
web site :  www.xpectis.com www.xpectis.com 
My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: http://www.nabble.com/ClientProxyFactoryBean-return-null-%21%21%21-tp19876268p19876268.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: ClientProxyFactoryBean return null !!!

Posted by cmoulliard <cm...@gmail.com>.
I have investigated a little bit more my case and discovered that the SOAP
communication works well. 

4308-oct.-2008 16:05:57
org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
INFO: Outbound Message
---------------------------
Encoding: UTF-8
Headers: {SOAPAction=[""], Accept=[*]}
Messages: 
Payload: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:PostParcel
xmlns:ns1="http://tracker.service.xpectis.com/"><ns2:inputTrackParcel
xmlns:ns2="http://tracker.service.xpectis.com"><name>chm</name><destination>Brussels</destination><origin>Florennes</origin></ns2:inputTrackParcel></ns1:PostParcel></soap:Body></soap:Envelope>
--------------------------------------
08-oct.-2008 16:05:57 org.apache.cxf.interceptor.LoggingInInterceptor
logging
INFO: Inbound Message
----------------------------
Encoding: UTF-8
Headers: {content-type=[text/xml; charset=utf-8], Content-Length=[228],
Server=[Jetty(6.1.9)]}
Messages: 
Message:

Payload: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:outputTrackParcel
xmlns:ns2="http://tracker.service.xpectis.com"><reference>14</reference></ns2:outputTrackParcel></soap:Body></soap:Envelope>
--------------------------------------

Unfortunately, the outputTrackParcel receiving the result is always null.

Can someone help me please ?

Charles Moulliard


cmoulliard wrote:
> 
> Hi,
> 
> I have a strange problem when I use ClientProxyFactoryBean. I have created
> a Cxf project (using cxf 2.1.2) and generated code from my WSDL file using
> wsdl2java generator.
> 
> In the following unit test, the result of the web service call is NULL. 
> 
> 	private static String ADDRESS = "http://localhost:9000/unittesttrack";
> 	
> 	@BeforeClass
>     public static void startServer() throws Exception {
>         // We need to start a server that exposes or webservice during the
> unit testing
>         // We use jaxws to do this pretty simple
>     	TrackerServiceImpl server = new TrackerServiceImpl();
>         Endpoint.publish(ADDRESS, server);
> 
>     }
> 	
> 	@Test
> 	public void serverStarted() throws Exception {
>     	// Start server
>     	this.startServer();
> 	}
> 	
> 
> 	@Test
> 	public void shouldGenerateWsdl() throws Exception {
> 		URL url = new URL(ADDRESS + "?wsdl");
> 		URLConnection connection = url.openConnection();
> 		Assert.assertNotNull(connection.getContent());
> 		showResponse(connection);
> 	}
> 
> 	@Test
> 	public void shouldHaveParcelViaWebService() throws Exception {
> 	   	XMLGregorianCalendar calendar =
> DatatypeFactory.newInstance().newXMLGregorianCalendar( new
> GregorianCalendar());
>     	calendar.setDay(7);
>     	calendar.setMonth(10);
>     	calendar.setYear(2008);
>     	
>     	// Create web service client
>     	createWebServiceClient();
> 		
>     	TrackParcelEndpoint client = createWebServiceClient();
> 		InputTrackParcel parcel = new InputTrackParcel();
> 		parcel.setName("chm");
> 		parcel.setDestination("Brussels");
> 		parcel.setOrigin("Florennes");
> 		parcel.setDeliveryDate(calendar);
> 		
> 		OutputTrackParcel result = client.PostParcel(parcel);
> 		Log.info("Result : " + result.getReference()); <<<<<  NULL POINTER
> EXCEPTION IS GENERATED HERE
> 		Assert.assertNotNull(result);
> 	}
> 
> 	private TrackParcelEndpoint createWebServiceClient() {
>       	
> 		ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
> 		factory.setServiceClass(TrackParcelEndpoint.class);
> 		factory.setAddress(ADDRESS);
> 		TrackParcelEndpoint client = (TrackParcelEndpoint) factory.create();
> 		return client;
> 	}
> 
> Surprisingly, if I try to connect to the server using the SOAPUI client,
> my SOAPUI client receives a reply from the service.
> 
> How can I solve/debug my problem ?
> 
> Charles Moulliard
> 


-----
Enterprise Architect

Xpectis
12, route d'Esch
L-1470 Luxembourg

Phone +352 25 10 70 470
Mobile +352 621 45 36 22

e-mail : cmoulliard@xpectis.com
web site :  www.xpectis.com www.xpectis.com 
My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: http://www.nabble.com/ClientProxyFactoryBean-return-null-%21%21%21-tp19876268p19879532.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: ClientProxyFactoryBean return null !!!

Posted by Daniel Kulp <dk...@apache.org>.
If you generated code with wsdl2java, it's a JAX-WS interface (with 
@WebService and @WebParam and such).  Thus, use:

ClientProxyFactoryBean factory = new JaxWsProxyFactoryBean();

Otherwise, those annotations and such won't be picked up (simple 
frontend).

Dan





On Wednesday 08 October 2008, cmoulliard wrote:
> Hi,
>
> I have a strange problem when I use ClientProxyFactoryBean. I have
> created a Cxf project (using cxf 2.1.2) and generated code from my
> WSDL file using wsdl2java generator.
>
> In the following unit test, the result of the web service call is
> NULL.
>
> 	private static String ADDRESS =
> "http://localhost:9000/unittesttrack";
>
> 	@BeforeClass
>     public static void startServer() throws Exception {
>         // We need to start a server that exposes or webservice during
> the unit testing
>         // We use jaxws to do this pretty simple
>     	TrackerServiceImpl server = new TrackerServiceImpl();
>         Endpoint.publish(ADDRESS, server);
>
>     }
>
> 	@Test
> 	public void serverStarted() throws Exception {
>     	// Start server
>     	this.startServer();
> 	}
>
>
> 	@Test
> 	public void shouldGenerateWsdl() throws Exception {
> 		URL url = new URL(ADDRESS + "?wsdl");
> 		URLConnection connection = url.openConnection();
> 		Assert.assertNotNull(connection.getContent());
> 		showResponse(connection);
> 	}
>
> 	@Test
> 	public void shouldHaveParcelViaWebService() throws Exception {
> 	   	XMLGregorianCalendar calendar =
> DatatypeFactory.newInstance().newXMLGregorianCalendar( new
> GregorianCalendar());
>     	calendar.setDay(7);
>     	calendar.setMonth(10);
>     	calendar.setYear(2008);
>
>     	// Create web service client
>     	createWebServiceClient();
>
>     	TrackParcelEndpoint client = createWebServiceClient();
> 		InputTrackParcel parcel = new InputTrackParcel();
> 		parcel.setName("chm");
> 		parcel.setDestination("Brussels");
> 		parcel.setOrigin("Florennes");
> 		parcel.setDeliveryDate(calendar);
>
> 		OutputTrackParcel result = client.PostParcel(parcel);
> 		Log.info("Result : " + result.getReference()); <<<<<  NULL POINTER
> EXCEPTION IS GENERATED HERE
> 		Assert.assertNotNull(result);
> 	}
>
> 	private TrackParcelEndpoint createWebServiceClient() {
>
> 		ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
> 		factory.setServiceClass(TrackParcelEndpoint.class);
> 		factory.setAddress(ADDRESS);
> 		TrackParcelEndpoint client = (TrackParcelEndpoint) factory.create();
> 		return client;
> 	}
>
> Surprisingly, if I try to connect to the server using the SOAPUI
> client, my SOAPUI client receives a reply from the service.
>
> How can I solve/debug my problem ?
>
> Charles Moulliard
>
> -----
> Enterprise Architect
>
> Xpectis
> 12, route d'Esch
> L-1470 Luxembourg
>
> Phone +352 25 10 70 470
> Mobile +352 621 45 36 22
>
> e-mail : cmoulliard@xpectis.com
> web site :  www.xpectis.com www.xpectis.com
> My Blog :  http://cmoulliard.blogspot.com/
> http://cmoulliard.blogspot.com/



-- 
J. Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog