cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thierry.M" <montule.thie...@neuf.fr>
Subject Strange unmarshalling error. Request parameter becomes null.
Date Wed, 27 Aug 2008 20:09:10 GMT

Hi every body.

I have generated a simple webservice from wsdl with CXF 2.1.2 . I have
deployed it on Tomcat and it works fine. Now I have tried to write unit
tests like that :

	@Test
	public void shouldListArticlesViaWebService() throws Exception {

		JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
		sf.getServiceFactory().setDataBinding(new JAXBDataBinding());
		sf.setServiceClass(CurrencyConvertImpl.class);
		sf.setAddress("http://localhost:8080/service");

		List<Interceptor> list = new ArrayList<Interceptor>();
		list.add(new org.apache.cxf.interceptor.LoggingInInterceptor());
		list.add(new org.apache.cxf.interceptor.LoggingOutInterceptor());
		sf.setInInterceptors(list);
		sf.create();

		ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
		factory.setServiceClass(CurrencyConvert.class);
		factory.setAddress("http://localhost:8080/service");
		CurrencyConvert client = (CurrencyConvert) factory.create();
		
		ConversionResponse cresp = null;
		ConversionRequest creqt = new ConversionRequest();
		creqt.setAmount(100F);
		cresp = client.convert(creqt);
		Assert.assertNotNull(cresp);
	}

The call and the payload are OK (I find the amount and fromCurrency):
Payload: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:convert
xmlns:ns1="http://service.pmodec.bdf.fr/"><ns3:conversionRequest
xmlns:ns2="http://pmodec.bdf.fr/service/common_types"
xmlns:ns3="http://pmodec.bdf.fr/service/types"><fromCurrency>DOLLAR</fromCurrency><amount>100.0</amount></ns3:conversionRequest></ns1:convert></soap:Body></soap:Envelope>


But inside the sercice method the parameter object is instancied but all
attributes are not initialized with the proper values. Same thing for the
return object in the caller. It is just null ! No logging for
outgoingmessage is displayed as well.

What's happened ? Any idea ?



My wsdl :

<?xml version="1.0" encoding="UTF-8"?>

<definitions xmlns:types="http://pmodec.bdf.fr/service/types"
	xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
	xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
	xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
	xmlns:y="http://pmodec.bdf.fr/service"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
	xmlns="http://schemas.xmlsoap.org/wsdl/" name="PmodecService"
	targetNamespace="http://pmodec.bdf.fr/service">
	<types>
		<xs:schema targetNamespace="http://pmodec.bdf.fr/service/types"
			xmlns:common="http://pmodec.bdf.fr/service/common_types"
			xmlns:tns="http://pmodec.bdf.fr/service/types">
			<xs:import
				namespace="http://pmodec.bdf.fr/service/common_types"
				schemaLocation="../xsd/common_financial_types.xsd" />
			<xs:element name="conversionRequest">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="fromCurrency"
							type="xs:string" />
						<xs:element name="toCurrency" type="xs:string" />
						<xs:element name="amount" type="xs:float" />
						<xs:element name="dateOnly" type="xs:date" />
						<xs:element name="dateTime" type="xs:dateTime" />
						<xs:element name="position" type="common:PositionType" />
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="conversionResponse">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="id" type="xs:int" />
						<xs:element name="amount" type="xs:float" />
						<xs:element name="dateOnly" type="xs:date" />
						<xs:element name="dateTime" type="xs:dateTime" />
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="exceptionDetail">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="minor" type="xs:short" />
						<xs:element name="major" type="xs:short" />
					</xs:sequence>
				</xs:complexType>
			</xs:element>
		</xs:schema>
	</types>
	<message name="conversionRequestMessage">
		<part name="request" element="types:conversionRequest" />
	</message>
	<message name="conversionResponseMessage">
		<part name="response" element="types:conversionResponse" />
	</message>
	<message name="exceptionDetailMessage">
		<part name="exception" element="types:exceptionDetail" />
	</message>
	<portType name="currencyConvert">
		<operation name="convert">
			<input name="toSend" message="y:conversionRequestMessage" />
			<output name="toReceive"
				message="y:conversionResponseMessage">
			</output>
			<fault name="toCatch" message="y:exceptionDetailMessage" />
		</operation>
	</portType>
	<binding name="currencyConvertBinding" type="y:currencyConvert">
		<soap:binding style="document"
			transport="http://schemas.xmlsoap.org/soap/http" />
		<operation name="convert">
			<soap:operation soapAction="" style="document" />
			<input>
				<soap:body use="literal" />
			</input>
			<output>
				<soap:body use="literal" />
			</output>
			<fault name="toCatch">
				<soap:fault name="toCatch" use="literal" />
			</fault>
		</operation>
	</binding>
	<service name="currencyConverterService">
		<port name="converterSoapPort"
			binding="y:currencyConvertBinding">
			<soap:address
				location="http://localhost:8080/services/currencyConverterService" />
		</port>
	</service>
	<!-- 
		MESSAGE
	-->
	<!-- 
		PORT
	-->
</definitions>

The imported XSD :

<?xml version="1.0" encoding="UTF-8"?>
<!-- This schema only describes financial common types. It only contains
types which are needed in those schemas, but no elements. -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://pmodec.bdf.fr/service/common_types"
targetNamespace="http://pmodec.bdf.fr/service/common_types"
elementFormDefault="qualified" attributeFormDefault="unqualified">

	<!-- PositionType definition -->
			<xs:complexType name="PositionType">
				<xs:sequence>
					<xs:element name="id" type="xs:long"/>
					<xs:element name="bafiCode" type="xs:string"/>
					<xs:element name="description" type="xs:string"/>
					<xs:element name="startDate" type="xs:dateTime"/>
				</xs:sequence>
			</xs:complexType>

</xs:schema>












-- 
View this message in context: http://www.nabble.com/Strange-unmarshalling-error.-Request-parameter-becomes-null.-tp19188748p19188748.html
Sent from the cxf-user mailing list archive at Nabble.com.


Mime
View raw message