Hi Everyone,

Now, I got the trouble with format date in SOAP webservice which created by Ivy

alt text

When I call it by SOAP client, I always got the exception like Unmarshalling Error: 28.08.2016 Because as we know, the expected format for date in XML is: YYYY-MM-DDThh:mm:ss. But I want to use the custom format like dd.MM.YYYY

Do you have any ideas about that?


asked 29.09.2016 at 07:51

vhsvuong's gravatar image

accept rate: 0%

edited 03.10.2016 at 12:23

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦

You can implement a custom adapter that parses your special date format string into a valid date.

package xmlhelper;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.bind.annotation.adapters.XmlAdapter;

public class DateAdapter extends XmlAdapter<String, Date> {

    private SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");

    public String marshal(Date v) throws Exception {
        return dateFormat.format(v);

    public Date unmarshal(String v) throws Exception {
        return dateFormat.parse(v);

To use it in your webservice you have to modify the generated webservice source class. Simply add an @XmlJavaTypeAdapter annotation into your method parameter definiton:

  public CallResult call(
          java.util.Date createJavaDataSaved)
    throws ch.ivyteam.ivy.webservice.process.restricted.WebServiceProcessTechnicalException

Remember that the generated webservice source will be overwritten whenever you change the mod file of the webservice. So you should at least write a test against your webservice stub so that you get an early warning if the adapter is not in charge anymore.

alt text You can inspect a full sample implementation here: webserviceProviderWithSpecialDateFormat_63.iar


answered 03.10.2016 at 13:41

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
accept rate: 70%

edited 03.03 at 15:55

admin's gravatar image

admin ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 29.09.2016 at 07:51

Seen: 452 times

Last updated: 03.03 at 15:55