开发者

Problem with Date type on CXF endpoint returning null

I've configured a simple CXF endpoint with spring which exposes a simple object with a java.util.Date property. once remotely invoked with a .NET client the date property is always null.

endpoint:

<jaxws:endpoint id="simpleService" implementor="cxf.base.SimpleServiceImpl" address=&qu开发者_如何转开发ot;/SimpleService" />

.NET call:

    SimpleServiceClient client = new SimpleServiceClient();
    simpleObject simpleObject = new simpleObject();
    simpleObject.date = new DateTime(2010, 1, 1);
    simpleObject.name = "Simple Object";

    txtResult.Text = client.toString(simpleObject);

where toString is the exposed webservice method.

Any idea what I am missing here?


I guess it's in the marshall phase on the server-side that's has the bug. If you're not sure, then do some logging on the server-side. Also, a tcp/ip monitor can show the SOAP elements transferred. Eclipse for example has an excellent tcp/ip monitor view.

If it's a marshall bug, and you marshall with JAXB, then you must convert the java.util.Date value to a javax.xml.datatype.XMLGregorianCalendar value.

This can be done with the javax.xml.datatype.DatatypeFactory class.

Be sure to use the overloaded newXMLGregorianCalendar() method that matches your date element.

A page with good information about the different date and time XSD elements: http://www.w3schools.com/Schema/schema_dtypes_date.asp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜