Can JAX-WS display XSD date (xs: dateTime) in a Java calendar?

Can JAX-WS map XML ( xs:dateTime) schema date , including its timezone, to Java Calendar?

+3
source share
2 answers

Yes it is possible.

The first approach to the contract
you need to use the element jaxb:javaType. There is general information here and an example of what you need to do here .

Last contract approach

@WebMethod(operationName = "getTest")
public Calendar getTest(@WebParam(name = "input") Calendar input) {
  input.roll(Calendar.DAY_OF_YEAR, 1);
  return input
}

The following is displayed:

<xs:complexType name="getTest">
  <xs:sequence>
    <xs:element name="input" type="xs:dateTime" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>

<xs:complexType name="getTestResponse">
  <xs:sequence>
    <xs:element name="return" type="xs:dateTime" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>
+2
source

, ; JAXB ( , JAX-WS) , XML java.util.Calendar.

, / , XML, - javax.xml.datatype.XMLGregorianCalendar, toGregorianCalendar() ( java.util.GregorianCalendar, java.util. ). , - , XMLGregorianCalendar, / . XMLJavaTypeAdapter.

+1

Source: https://habr.com/ru/post/1775297/


All Articles