:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.



== Usage Notes

The value of the `x-ro-domain-type` parameter corresponds to the DTO to be mapped into by the xref:refguide:applib:index/services/conmap/ContentMappingService.adoc[ContentMappingService].

If the DTO is annotated with JAXB, then also note that the runtime type must be annotated with the JAXB `javax.xml.bind.annotation.XmlRootElement` so that RestEasy is able to unambiguously serialize it.


== Example

For example, consider a todo app that defines a  `ToDoItemDto` class, generated from an XSD and therefore JAXB annotated.

An implementation of `ContentMappingService` that maps the application's `todoapp.dom.module.todoitem.ToDoItem` entities into `todoapp.dto.module.todoitem.ToDoItemDto` classes.

A REST client can therefore request a DTO representation of an entity by invoking

[source]
----
http://localhost:8080/restful/objects/TODO/0
----

with an `Accept` header of:

[source]
----
application/xml;profile=urn:org.restfulobjects:repr-types/object;x-ro-domain-type=todoapp.dto.module.todoitem.ToDoItemDto
----

will result in an XML serialization of that class:

image::index/restfulobjects/rendering/service/conneg/accept-xml.png[width="700px"]


while similarly hitting the same URL with an `Accept` header of:

[source]
----
application/json;profile=urn:org.restfulobjects:repr-types/object;x-ro-domain-type=todoapp.dto.module.todoitem.ToDoItemDto
----

will result in the JSON serialization of that class:

image::index/restfulobjects/rendering/service/conneg/accept-json.png[width="700px"]
