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

Difference between revisions of "Texo/XML REST Web Services"

(Query Example)
Line 9: Line 9:
  
 
Most/all of [[Texo/JSON_REST_Web_Services|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.
 
Most/all of [[Texo/JSON_REST_Web_Services|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:
 +
* http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/Writer/100
 +
 +
The result:
 +
<source lang="xml"><?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# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/513# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/514# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/515# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/516# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/517# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/518# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/519# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/520#" texoExtensions:id="100" texoExtensions:title="libertatis iustae servitus propria oppressus" texoExtensions:type="library|Writer"/>
 +
</source>
  
 
== Query Example ==
 
== Query Example ==

Revision as of 16:19, 4 April 2012

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)

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# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/513# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/514# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/515# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/516# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/517# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/518# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/519# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/520#" texoExtensions:id="100" texoExtensions:title="libertatis iustae servitus propria oppressus" texoExtensions:type="library|Writer"/>

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# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/983# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/984# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/985# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/986# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/987# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/988# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/989# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/990#" 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# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/253# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/254# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/255# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/256# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/257# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/258# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/259# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/260#" 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# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/473# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/474# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/475# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/476# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/477# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/478# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/479# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/480#" 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# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/623# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/624# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/625# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/626# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/627# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/628# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/629# library:Book http://localhost:8080/org.eclipse.emf.texo.web.example/xmlws/library|Book/630#" 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