Search code examples
soapjax-ws

JAX-WS xsi:type attributes missing


I have a JAX-WS webservice that works just fine except that the return elements are missing necessary xsi:type attributes.

response:

<ns1:isUserValidResponse xmlns:ns1="http://www.openuri.org/">
     <isUserValidResult>true</isUserValidResult>
</ns1:isUserValidResponse>

desired response:

<ns:isUserValidResponse xmlns:ns="http://www.openuri.org/">
     <isUserValidResult xsi:type="xsd:boolean">true</isUserValidResult>
</ns:isUserValidResponse>

Is there anyway to force this behavior?


Solution

  • I resolved this issue by using @XmlAttribute with the name being "xsi:type" and the value being "xsd:boolean" as shown below. This feels extremely hacky to me but it works in the mean time.

    @XmlAttribute(name="xsi:type")
    private String xsiType = "xsd:boolean";