Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to invoke any servlet at publish instance in workflow step ?

Avatar

Avatar
Springboard
MVP
Suraj_Kamdi
MVP

Likes

142 likes

Total Posts

156 posts

Correct Reply

41 solutions
Top badges earned
Springboard
Validate 1
Establish
Contributor
Ignite 3
View profile

Avatar
Springboard
MVP
Suraj_Kamdi
MVP

Likes

142 likes

Total Posts

156 posts

Correct Reply

41 solutions
Top badges earned
Springboard
Validate 1
Establish
Contributor
Ignite 3
View profile
Suraj_Kamdi
MVP

29-01-2019

I want to invoke the custom servlet to perform some action in publish server through custom workflow step. Anyone has idea how to achieve this scenario ?

Replies

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

29-01-2019

Yes - but why not implement a service (as opposed to a Servlet) then you can use @Reference annotation from within your custom step to invoke the Java logic.

Avatar

Avatar
Springboard
MVP
Suraj_Kamdi
MVP

Likes

142 likes

Total Posts

156 posts

Correct Reply

41 solutions
Top badges earned
Springboard
Validate 1
Establish
Contributor
Ignite 3
View profile

Avatar
Springboard
MVP
Suraj_Kamdi
MVP

Likes

142 likes

Total Posts

156 posts

Correct Reply

41 solutions
Top badges earned
Springboard
Validate 1
Establish
Contributor
Ignite 3
View profile
Suraj_Kamdi
MVP

29-01-2019

as per the acceptance criteria i have to invoke servlet from custom workflow step. Currently i am using CloseableHttpClient closeableHttpClient to invoke servlet.

Avatar

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
Gaurav-Behl
MVP

29-01-2019

Based on your project's design and requirements whatever you choose to use (either servlet or service or just a component), the underlying logic would primarily work in same manner -  Get hold of server's runmode and process your custom code.

To get the run mode in server side code -

Slice-CQ/WcmModeModel.java at master · Cognifide/Slice-CQ · GitHub

or use

final WCMMode mode = WCMMode.fromRequest(request);

if (null == mode || WCMMode.DISABLED.equals(mode)) { // do something }

*you would find WCMMode in uber-jar

Create your workflow, register it and use WCMMode to excute it only on publish server. Once everything is done, configure this workflow step in your custom workflow.

Example -

Adobe Experience Manager Help | Invoking Adobe Experience Manager Workflows using the AEM Java API

Hope that helps.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

29-01-2019

If you requirement is to invoke a Servlet as opposed to an AEM Service, then write Java code from your custom step that can perform a GET operation on a servlet.

How do I do a HTTP GET in Java? - Stack Overflow

Avatar

Avatar
Level 1
mvip
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
mvip
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
mvip
Level 1

29-01-2019