Last active
April 24, 2018 18:15
-
-
Save cjmamo/5215459 to your computer and use it in GitHub Desktop.
How To Publish a WADL with Mule's REST Router Module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <application xmlns="http://research.sun.com/wadl/2006/10"> | |
| <doc xmlns:jersey="http://jersey.dev.java.net/" jersey:generatedBy="Jersey: 1.6 03/25/2011 01:14 PM"/> | |
| <resources base="http://localhost:8081/"> | |
| <resource path="/{userid}/comments/{title}/feed"> | |
| <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" style="template" name="title"/> | |
| <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" style="template" name="userid"/> | |
| <method name="PUT" id="createComment"> | |
| <response> | |
| <representation mediaType="*/*"/> | |
| </response> | |
| </method> | |
| <method name="GET" id="retrieveComment"> | |
| <response> | |
| <representation mediaType="*/*"/> | |
| </response> | |
| </method> | |
| <method name="POST" id="updateComment"> | |
| <response> | |
| <representation mediaType="*/*"/> | |
| </response> | |
| </method> | |
| <method name="DELETE" id="deleteComment"> | |
| <response> | |
| <representation mediaType="*/*"/> | |
| </response> | |
| </method> | |
| </resource> | |
| </resources> | |
| </application> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mvn package |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.ossandme; | |
| import javax.ws.rs.*; | |
| @Path("/{userid}/comments/{title}/feed") | |
| public interface CommentResource { | |
| @GET | |
| public String retrieveComment(@PathParam("userid") String userID, @PathParam("title") String title); | |
| @PUT | |
| public String createComment(@PathParam("userid") String userID, @PathParam("title") String title); | |
| @POST | |
| public String updateComment(@PathParam("userid") String userID, @PathParam("title") String title); | |
| @DELETE | |
| public String deleteComment(@PathParam("userid") String userID, @PathParam("title") String title); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <mule xmlns="http://www.mulesoft.org/schema/mule/core" | |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xmlns:http="http://www.mulesoft.org/schema/mule/http" | |
| xmlns:rest-router="http://www.mulesoft.org/schema/mule/rest-router" | |
| xsi:schemaLocation=" | |
| http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd | |
| http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd | |
| http://www.mulesoft.org/schema/mule/rest-router http://www.mulesoft.org/schema/mule/rest-router/current/mule-rest-router.xsd"> | |
| <flow name="commentsFlow"> | |
| <http:inbound-endpoint address="http://localhost:8081" exchange-pattern="request-response"/> | |
| <rest-router:router templateUri="/{userid}/comments/{title}/feed"> | |
| <rest-router:get> | |
| <expression-transformer | |
| expression="#['Retrieving comment on ' + flowVars['title'] + ' for user ' + flowVars['userid']]"/> | |
| </rest-router:get> | |
| <rest-router:put> | |
| <expression-transformer | |
| expression="#['Creating comment on ' + flowVars['title'] + ' for user ' + flowVars['userid']]"/> | |
| </rest-router:put> | |
| <rest-router:post> | |
| <expression-transformer | |
| expression="#['Updating comment on ' + flowVars['title'] + ' for user ' + flowVars['userid']]"/> | |
| </rest-router:post> | |
| <rest-router:delete> | |
| <expression-transformer | |
| expression="#['Deleting comment on ' + flowVars['title'] + ' for user ' + flowVars['userid']]"/> | |
| </rest-router:delete> | |
| </rest-router:router> | |
| <static-component> | |
| <return-data>Invalid URL :-(</return-data> | |
| </static-component> | |
| </flow> | |
| </mule> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <mule xmlns="http://www.mulesoft.org/schema/mule/core" | |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xmlns:http="http://www.mulesoft.org/schema/mule/http" | |
| xmlns:rest-router="http://www.mulesoft.org/schema/mule/rest-router" | |
| xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey" | |
| xsi:schemaLocation=" | |
| http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd | |
| http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd | |
| http://www.mulesoft.org/schema/mule/rest-router http://www.mulesoft.org/schema/mule/rest-router/current/mule-rest-router.xsd | |
| http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.xsd"> | |
| <flow name="commentsFlow"> | |
| <http:inbound-endpoint address="http://localhost:8081" exchange-pattern="request-response"/> | |
| <choice> | |
| <when expression="#[message.inboundProperties['http.relative.path'] == 'application.wadl']"> | |
| <jersey:resources> | |
| <component class="org.ossandme.CommentResource"/> | |
| </jersey:resources> | |
| </when> | |
| <otherwise> | |
| <rest-router:router templateUri="/{userid}/comments/{title}/feed"> | |
| <rest-router:get> | |
| <expression-transformer | |
| expression="#['Retrieving comment on ' + flowVars['title'] + ' for user ' + flowVars['userid']]"/> | |
| </rest-router:get> | |
| <rest-router:put> | |
| <expression-transformer | |
| expression="#['Creating comment on ' + flowVars['title'] + ' for user ' + flowVars['userid']]"/> | |
| </rest-router:put> | |
| <rest-router:post> | |
| <expression-transformer | |
| expression="#['Updating comment on ' + flowVars['title'] + ' for user ' + flowVars['userid']]"/> | |
| </rest-router:post> | |
| <rest-router:delete> | |
| <expression-transformer | |
| expression="#['Deleting comment on ' + flowVars['title'] + ' for user ' + flowVars['userid']]"/> | |
| </rest-router:delete> | |
| </rest-router:router> | |
| <static-component> | |
| <return-data>Invalid URL :-(</return-data> | |
| </static-component> | |
| </otherwise> | |
| </choice> | |
| </flow> | |
| </mule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment