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

Call servlet dopost programmatically

Avatar

Avatar
Validate 1
Level 3
sr508
Level 3

Likes

2 likes

Total Posts

51 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile

Avatar
Validate 1
Level 3
sr508
Level 3

Likes

2 likes

Total Posts

51 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile
sr508
Level 3

11-06-2018

Hi,

I am trying to play around with acs common feature Querypackager .

Querypackager servlet is registered with resourcetype and have selector and extension.

I would like to programmatically call this servlet from my workflow.

I am getting 500 response. I am having following queries :

  • I am getting an exception in error log ,

        illegalargumentexception: cannot create a node on synthetic resource and ModifiableNode exception.

     I have googled and ended up finding none to resolve the issue.

  • I have referred the following link calling a servlet.

          Adobe Experience Manager Help | Invoking Adobe Experience Manager Sling Servlets using Apache HTTP A...

     I have followed the same ay for calling he doos bt ith resorcetye.

     My resource type is resolving in resource resolver and i am calling with _jcr_content.package.json

     i didnt find any other way how to implement.

     Is there any other way to implement the servlets registered with resourcetype.

  • The page where the servlet is triggered is located in /etc/acs-commons.

     I have the user with admin permissions, do i need to pass the csrf token programmatically set in the headers of the http post method?

  • What are all the headers and parms need to set to call a post servlet

Please provide any references and solutions to above.

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

11-06-2018

Is this Servlet registered by Resource type? If so - will be hard to invoke from a WOrkflow. If reg by resource type, you need:

The resource type(s) supported by the servlet. The property value must either be a single String, an array of Strings or a Vector of Strings. Either this property or the sling.servlet.paths property must be set, or the servlet is ignored. If both are set, the servlet is registered using both ways.

See this doc for an explanation -- Apache Sling :: Servlets and Scripts

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

11-06-2018

If you want to call an AEM Service from a Workflow, create a custom AEM Service that contains QueryBuilder logic to do what you want. Write a custom AEM workflow step that invokes the custom service using @Reference annotation. That will invoke your service.  

Avatar

Avatar
Validate 1
Level 3
sr508
Level 3

Likes

2 likes

Total Posts

51 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile

Avatar
Validate 1
Level 3
sr508
Level 3

Likes

2 likes

Total Posts

51 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile
sr508
Level 3

12-06-2018

Hi scott,

I have implemented using bundles .... it worked.

But i want to know the real difficulty in calling the servlet  registered by resource type through http post.

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

13-06-2018

It won;t work through a POST. That is because a Servlet registered via a resource type and is fired when that resource type is accessed- not in response to an event - like when we click a button - such as a submit button on a component.

See this doc for more information -- Scott's Digital Community: Binding Adobe Experience Manager Servlets to ResourceTypes

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,089 likes

Total Posts

3,121 posts

Correct Reply

1,063 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,089 likes

Total Posts

3,121 posts

Correct Reply

1,063 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

13-06-2018

In your case I would re-implement the logic of the QueryServlet in your own code. A lot of code of this servlet is validating things and rerouting paramters to do some API calls. And instead of creating a wrapper around this wrapper servlet, study the code and use the QueryHelper services (and some others) to do that what you want.

Jörg