ATG 11 REST call with parameters

I need to call a method using ATG 11 REST API.

public String getString(String str) {
     return str;
}

      

I created an actor properties config like this:

$class=atg.service.actor.ActorChainService
definitionFile=/path/to/service/accountServiceActor.xml

      

And that's my accountServiceActor.xml:

<?xml version="1.0" encoding="UTF-8"?>
<actor-template default-chain-id="cartService"  xsi:noNamespaceSchemaLocation="http://www.atg.com/xsds/actorChain_1.0.xsd"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <actor-chain id="getString" transaction="TX_SUPPORTS">
        <component id="getString" name="/path/to/service/AccountService"
                   method="getString" method-return-var="str">
            <input name="str" value="${param.str}" />
            <output id="str" name="str" value="${str}" />
        </component>
    </actor-chain>
</actor-template>

      

Also I have updated AccessControlServlet.properties and ActorChainRestRegistry.properties

So my stay is here:

curl -L -v -b customer_cookies.txt -X POST -H "Content-Type: application/json" -d '{ "str" : "value" }' http://localhost:7003/path/to/service/AccountServiceActor/getString

      

And I am getting this error:

* Adding handle: conn: 0x7f8eb9803000
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f8eb9803000) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 7003 (#0)
*   Trying ::1...
* Connected to localhost (::1) port 7003 (#0)
> POST /path/to/service/AccountServiceActor/getString HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost:7003
> Accept: */*
> Cookie: DYN_USER_CONFIRM=f0f599f9f11aa5571d7055c2b4c7c9d5; DYN_USER_ID=240004; JSESSIONID=6iUR5qvjjBHPhSNq6zMh_B6dn18lwhKFWvPbOZxTekUIhsFPqf3r!-1528908093
> Content-Type: application/json
> Content-Length: 20
>
* upload completely sent off: 20 out of 20 bytes
< HTTP/1.1 500 Internal Server Error
< Connection: close
< Date: Tue, 26 Aug 2014 11:19:21 GMT
< Content-Length: 265
< Content-Type: text/html; charset=UTF-8
< X-ATG-Version: version=QVRHUGxhdGZvcm0vMTEuMA==
* Replaced cookie JSESSIONID="fcMSCqdKrO-PvMyLalmJHSnuHBa0VEBaJscD01nZYZDOXCXs6Q3j!-1528908093" for domain localhost, path /, expire 0
< Set-Cookie: JSESSIONID=fcMSCqdKrO-PvMyLalmJHSnuHBa0VEBaJscD01nZYZDOXCXs6Q3j!-1528908093; path=/; HttpOnly
< X-Powered-By: Servlet/3.0 JSP/2.2
<
CONTAINER:atg.service.actor.ActorException: There was an error while trying to find a method.&#59; SOURCE:java.lang.NoSuchMethodException: path.to.service.impl.AccountService.getString&#40;null&#41;

      

What am I doing wrong? Help me set up my config correctly.

+3


source to share


3 answers


<input name="str" class-name="java.lang.String" value="${param.str}" /> 
      

Run codeHide result




Please add the class-name attribute to your snippet input parameter:

+1


source


1-Enclose http: // localhost: 7003 / path / to / service / AccountServiceActor / getString in double qoutes i.e. " http: // localhost: 7003 / path / to / service / AccountServiceActor / getString ".



2 - Also replace '{"str": "value"}' with "{" str ":" value "}"

0


source


Please check the following points:

  • The Actor property file name and Actionor xml file name must be the same i.e. in your case accountServiceActor.xml and AccountServiceActor.properties
  • Use the url with / rest / model / ie in your case http: // localhost: 7003 / rest / model / path / to / service / AccountServiceActor / getString
  • Make sure the URL is registered correctly in the ActorChainRestRegistry.propeties file i.e. in your case registeredUrls + = / path / to / service / accountServiceActor / getString
  • Make sure getString () method exists in component / path / in / service / AccountService :)
-1


source







All Articles