I'm receiving following error: "Unmarshalling Error: unexpected element
(uri:"", local:"from"). Expected elements are (none)". It occurs when
xs:dateTime is mapped to java.util.Calendar.
Here is the part of WSDL:
<xs:element name="getDownloadHistory" type="getDownloadHistory"/>
<xs:complexType name="getDownloadHistory">
<xs:sequence>
<xs:element minOccurs="0" name="application" type="xs:string"/>
<xs:element minOccurs="0" name="id" type="xs:string"/>
<xs:element minOccurs="0" name="type" type="historyType"/>
<xs:element minOccurs="0" name="from" type="xs:dateTime"/>
<xs:element minOccurs="0" name="to" type="xs:dateTime"/>
</xs:sequence>
</xs:complexType>
<xs:element name="getDownloadHistoryResponse"
type="getDownloadHistoryResponse"/>
<xs:complexType name="getDownloadHistoryResponse">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="return"
type="downloadRecord"/>
</xs:sequence>
</xs:complexType>
Here is the service interface:
List<DownloadRecord> getDownloadHistory(
@WebParam(name = "application")
final String applicationID,
@WebParam(name = "id")
final String userID,
@WebParam(name = "type")
final HistoryType type,
@WebParam(name = "from")
final Calendar from,
@WebParam(name = "to")
final Calendar to);
I'm using following SOAP binding:
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT,
use = SOAPBinding.Use.LITERAL,
parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
Here is a SOAP request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dow="http://www.volantis.com/xmlns/2008/01/mss/download-module">
<soapenv:Header/>
<soapenv:Body>
<dow:getDownloadHistory>
<!--Optional:-->
<application>111:222:op</application>
<!--Optional:-->
<id>666</id>
<!--Optional:-->
<type>ACTIVE</type>
<!--Optional:-->
<from>2007-02-17T14:40:32.000Z</from>
<to>2008-07-08T12:10:00.000Z</to>
</dow:getDownloadHistory>
</soapenv:Body>
</soapenv:Envelope>
And SOAP response:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Unmarshalling Error: unexpected element (uri:"",
local:"from"). Expected elements are (none)</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
It seems that everything is correctly configured but I still have the same
error. I've also tried to force conversion but adding XmlJavaTypeAdapter:
List<DownloadRecord> getDownloadHistory(
@WebParam(name = "application")
final String applicationID,
@WebParam(name = "id")
final String userID,
@WebParam(name = "type")
final HistoryType type,
@WebParam(name = "from")
@XmlJavaTypeAdapter(Adapters.CalendarAdapter.class)
final Calendar from,
@WebParam(name = "to")
@XmlJavaTypeAdapter(Adapters.CalendarAdapter.class)
final Calendar to);
public final class Adapters {
/**
* [EMAIL PROTECTED] Calendar} adapter.
*/
public static final class CalendarAdapter extends
XmlAdapter<GregorianCalendar, Calendar> {
@Override
public GregorianCalendar marshal(Calendar calendar) throws Exception
{
return (GregorianCalendar) calendar;
}
@Override
public Calendar unmarshal(GregorianCalendar calendar)
throws Exception {
return calendar;
}
}
}
But it doesn't work. It seems problem is somewhere earlier because converter
is not invoked.
I've found something similar but my SOAPBinding is correct.
--
View this message in context:
http://www.nabble.com/Problem-with-converting-to-Calendar-tp18359438p18359438.html
Sent from the cxf-user mailing list archive at Nabble.com.