Lets start with the service.xml file. It should probably look like the much
simpler version below. You would only need the more complex forms if you need
to apply specific rules to specific parts of requests or responses. Note that
ideally only one route would be required but the `**` in Knox means one or more
path levels (not zero or more). So without the first route Knox wouldn't send
requests to the root /Test_Web_App path to the service.
<service role="TEST_WEB_APP" name="Test_Web_App" version="0.0.1">
<routes>
<route path="/Test_Web_App/?**">
<route path="/Test_Web_App/**?**">
</routes>
</service>
If you wanted to be very specific about it this would be the equivalent. Here
the `<rewrite apply="">` identifies a specific named rule in rewrite.xml and
`<rewrite to="">` identifies what part of the request and or response the rule
should be applied to.
<service role="TEST_WEB_APP" name="Test_Web_App" version="0.0.1">
<routes>
<route path="/Test_Web_App/?**">
<rewrite apply="TEST_WEB_APP/Test_Web_App/" to="request.url"/>
</route>
<route path="/Test_Web_App/**?**">
<rewrite apply="TEST_WEB_APP/Test_Web_App/query"
to="request.url"/>
</route>
</routes>
</service>
Now for the rewrite.xml. Yours was pretty close. All I added was a name (i.e.
path) resulting in `{path=**}` to both the pattern and template of the second
rule. In the `<rule pattern="">` this is used to give a name to the values
that are extracted from the matched pattern. In `<rewrite template="">` the
name is used to populate part of the url being created with named values
extracted from the matched pattern.
<rules>
<rule dir="IN" name="TEST_WEB_APP/Test_Web_App"
pattern="*://*:*/**/Test_Web_App/?{**}">
<rewrite template="{$serviceUrl[TEST_WEB_APP]}/?{**}"/>
</rule>
<rule dir="IN" name="TEST_WEB_APP/Test_Web_App/query"
pattern="*://*:*/**/Test_Web_App/{path=**}?{**}">
<rewrite template="{$serviceUrl[TEST_WEB_APP]/{path=**}?{**}"/>
</rule>
</rules>
From: Brijan Elwadhi
<[email protected]<mailto:[email protected]>>
Date: Tuesday, January 26, 2016 at 1:36 AM
To: Kevin Minder
<[email protected]<mailto:[email protected]>>
Subject: KNOX
Hi Kevin,
After going through your mail and blog I came to know that we do not need to
implement contributor if we are using knox 0.6.0 or above, I have
followed the steps and I have added rewrite.xml service.xml in
GATEWAY_HOME/data/services/Test_Web_App/0.0.1
rewrite.xml:
<rules>
<rule dir="IN" name="TEST_WEB_APP/Test_Web_App"
pattern="*://*:*/**/Test_Web_App/?{**}">
<rewrite template="{$serviceUrl[TEST_WEB_APP]}/?{**}"/>
</rule>
<rule dir="IN" name="TEST_WEB_APP/Test_Web_App/query"
pattern="*://*:*/**/Test_Web_App/{**}?{**}">
<rewrite template="{$serviceUrl[TEST_WEB_APP]/{**}?{**}"/>
</rule>
</rules>
Service.xml:
<service role="TEST_WEB_APP" name="Test_Web_App" version="0.0.1">
<routes>
<route path="/Test_Web_App/**">
<rewrite apply="TEST_WEB_APP/Test_Web_App/**" to="response.body" />
</route>
<route path="/Test_Web_App/**?**">
<rewrite apply="TEST_WEB_APP/Test_Web_App/**?**" to="response.body"/>
</routes>
</service>
and this is what I have added in sandbox.xml (topology )
<service>
<role>TEST_WEB_APP</role>
<url>http://localhost:8087</url>
</service>
But it is not working. Can you please tell me what else I need to do? Or if I
am making any mistake
Thanks & Regards,
Brijan Elwadhi
Software Engineer
M: +91-7587130309
[cid:[email protected]]<http://www.resilinc.com/>
[facebook]<https://www.facebook.com/pages/Resilinc/152374944798272> [twitter]
<http://www.twitter.com/resilinc> [linkedin]
<http://www.linkedin.com/company/resilinc-corporation> [youtube]
<https://www.youtube.com/channel/UCbo4dHglF3tdc-h7Db8YaGw>
[cid:A961F978-0020-464D-A5C1-1AD0E6195E54]<https://www.eventbrite.com/e/2016-global-supply-chain-resiliency-council-conference-awards-registration-18740042973>