Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Texo/XML REST Web Services

< Texo(Redirected from Texo/XML Web Services)

Introduction

The XML REST web services follow the same structure and approach as the JSON REST web services. The documentation in that page also applies to the XML REST webservice layer, with the following remarks:

  • for the URL: in the JSON examples the url has a 'jsonws', for xml web services this should be replaced with 'xmlws'
  • XML web services expect XML in the request body (when posting/putting)
  • XML web services will return XML according to the ecore/XML schema as defined by the response schema (see JSON REST documentation)
  • one JSON feature not supported by the XML REST web service is the possibility to have several parts in the select clause of a query, so that an each row in the return is an array of values.

Most/all of the JSON REST web services documentation applies to the XML REST web services. Therefore this page only contains some examples of posting and receiving XML.


Get one object

The url:

The result:

<?xml version="1.0" encoding="UTF-8"?>
<library:Writer xmlns:library="http://www.eclipse.org/emf/texo/test/model/samples/library" xmlns:texoExtensions="http://www.eclipse.org/emf/texo/xml/model/texo_extensions" db_Id="100" db_version="1" 
name="libertatis iustae servitus propria oppressus" books="library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/511# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/512#" 
texoExtensions:id="100" texoExtensions:title="libertatis iustae servitus propria oppressus" texoExtensions:type="library|Writer"/>

Object meta data

Just as in the case of JSON Texo also adds metadata to the XML generated for an object. They are added in the texo_extensions namespace:

  • id: the database id
  • title: the title of an object, see here for more information
  • type: the type of the object, creating a unique name for the EClass

See here for more information on this metadata.

Get all objects of a certain type

The url:

The result:

<?xml version="1.0" encoding="UTF-8"?>
<response:response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:library="http://www.eclipse.org/emf/texo/test/model/samples/library" xmlns:response="http://www.eclipse.org/emf/texo/server/model/response" xmlns:texoExtensions="http://www.eclipse.org/emf/texo/xml/model/texo_extensions" texoExtensions:title="success" texoExtensions:type="response|ResponseType">
  <status>success</status>
  <startRow>0</startRow>
  <endRow>909</endRow>
  <totalRows>910</totalRows>
  <data xsi:type="library:Book" db_Id="333" db_version="1" title="ei qua iura Omnes exilio" pages="223" category="Mystery" author="library:Writer http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Writer/72#" texoExtensions:id="333" texoExtensions:title="ei qua iura Omnes exilio (223) - Mystery" texoExtensions:type="library|Book"/>
  <data xsi:type="library:Book" db_Id="438" db_version="1" title="ei qua iura Omnes exilio" pages="328" category="Mystery" author="library:Writer http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Writer/92#" texoExtensions:id="438" texoExtensions:title="ei qua iura Omnes exilio (328) - Mystery" texoExtensions:type="library|Book"/>
  <data xsi:type="library:Book" db_Id="871" db_version="1" title="poterit fiduciariae iuris constituantur criminis" pages="761" category="ScienceFiction" author="library:Writer http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Writer/176#" texoExtensions:id="871" texoExtensions:title="poterit fiduciariae iuris constituantur criminis (761) - ScienceFiction" texoExtensions:type="library|Book"/>
....
....
  <data xsi:type="library:Book" db_Id="352" db_version="1" title="sunt nullum ea incolumitatis discrimine" pages="242" category="ScienceFiction" author="library:Writer http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Writer/74#" texoExtensions:id="352" texoExtensions:title="sunt nullum ea incolumitatis discrimine (242) - ScienceFiction" texoExtensions:type="library|Book"/>
</response:response>

Query Example

The url:

The result:

<?xml version="1.0" encoding="UTF-8"?>
<response:response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:library="http://www.eclipse.org/emf/texo/test/model/samples/library" xmlns:response="http://www.eclipse.org/emf/texo/server/model/response" xmlns:texoExtensions="http://www.eclipse.org/emf/texo/xml/model/texo_extensions" texoExtensions:title="success" texoExtensions:type="response|ResponseType">
  <status>success</status>
  <startRow>0</startRow>
  <endRow>4</endRow>
  <totalRows>16</totalRows>
  <data xsi:type="library:Writer" db_Id="197" db_version="1" name="adhibendis ut liberum studio a" books="library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/981# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/982#" texoExtensions:id="197" texoExtensions:title="adhibendis ut liberum studio a" texoExtensions:type="library|Writer"/>
  <data xsi:type="library:Writer" db_Id="34" db_version="1" name="atrocibus conscientiae ubicumque regio obnoxii" books="library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/4#" texoExtensions:id="34" texoExtensions:title="atrocibus conscientiae ubicumque regio obnoxii" texoExtensions:type="library|Writer"/>
  <data xsi:type="library:Writer" db_Id="54" db_version="1" name="agendum cuius sive opinionis affici" books="library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/251# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/252#" texoExtensions:id="54" texoExtensions:title="agendum cuius sive opinionis affici" texoExtensions:type="library|Writer"/>
  <data xsi:type="library:Writer" db_Id="96" db_version="1" name="ab idonea iudices pari inter" books="library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/471# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/472#" texoExtensions:id="96" texoExtensions:title="ab idonea iudices pari inter" texoExtensions:type="library|Writer"/>
  <data xsi:type="library:Writer" db_Id="131" db_version="1" name="ab idonea iudices pari inter" books="library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/621# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/622#" texoExtensions:id="131" texoExtensions:title="ab idonea iudices pari inter" texoExtensions:type="library|Writer"/>
</response:response>

Error Example

This xml snippet shows how an error is returned in xml:

<?xml version="1.0" encoding="UTF-8"?>
<response:error xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:response="http://www.eclipse.org/emf/texo/server/model/response" xmlns:texoExtensions="http://www.eclipse.org/emf/texo/xml/model/texo_extensions" texoExtensions:title="java.lang.IllegalStateException" texoExtensions:type="response|ErrorType">
  <errorClass>java.lang.IllegalStateException</errorClass>
  <message>The class class [Ljava.lang.Object; is not managed by this ModelResolver</message>
  <stackTrace>java.lang.IllegalStateException: The class class [Ljava.lang.Object; is not managed by this ModelResolver
	at org.eclipse.emf.texo.utils.Check.isNotNull(Check.java:66)
	at org.eclipse.emf.texo.model.ModelResolver.getModelDescriptor(ModelResolver.java:290)
	at org.eclipse.emf.texo.model.ModelResolver.getModelObject(ModelResolver.java:233)
	at org.eclipse.emf.texo.resolver.DefaultObjectResolver.resolveToEObject(DefaultObjectResolver.java:74)
	at org.eclipse.emf.texo.xml.ModelEMFConverter.createTarget(ModelEMFConverter.java:136)
	at org.eclipse.emf.texo.xml.ModelEMFConverter.convertManyEReference(ModelEMFConverter.java:330)
	at org.eclipse.emf.texo.xml.ModelEMFConverter.convertContent(ModelEMFConverter.java:168)
	at org.eclipse.emf.texo.xml.ModelEMFConverter.convert(ModelEMFConverter.java:95)
	at org.eclipse.emf.texo.xml.ModelXMLSaver.write(ModelXMLSaver.java:83)
	at org.eclipse.emf.texo.server.store.ObjectStore.toXML(ObjectStore.java:262)
	at org.eclipse.emf.texo.server.service.xml.XMLServiceContext.convertToResultFormat(XMLServiceContext.java:62)
	at org.eclipse.emf.texo.server.service.ServiceContext.setResultInResponse(ServiceContext.java:216)
	at org.eclipse.emf.texo.server.service.RetrieveModelOperation.internalExecute(RetrieveModelOperation.java:126)
	at org.eclipse.emf.texo.server.service.ModelOperation.execute(ModelOperation.java:47)
	at org.eclipse.emf.texo.server.web.WebServiceHandler.doGet(WebServiceHandler.java:88)
	at org.eclipse.emf.texo.server.web.WebServiceServlet.doGet(WebServiceServlet.java:57)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.eclipse.emf.texo.server.store.CurrentEntityManagerRequestFilter.doFilter(CurrentEntityManagerRequestFilter.java:65)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
</stackTrace>
  <cause xsi:nil="true"/>
</response:error>

Back to the top