我需要使用ATG 11 REST API调用方法。
public String getString(String str) {
return str;
}
我创建了这样的actor属性配置:
$class=atg.service.actor.ActorChainService
definitionFile=/path/to/service/accountServiceActor.xml
那是我的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>
我还更新了 AccessControlServlet.properties 和 ActorChainRestRegistry.properties
所以我的休息电话就在这里:
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
我收到了这个错误:
* 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.; SOURCE:java.lang.NoSuchMethodException: path.to.service.impl.AccountService.getString(null)
我做错了什么?帮助我正确配置。
答案 0 :(得分:1)
<input name="str" class-name="java.lang.String" value="${param.str}" />
&#13;
请在输入参数中添加class-name属性:Snippet:
答案 1 :(得分:0)
1 - 将http://localhost:7003/path/to/service/AccountServiceActor/getString括在双qoutes中,即 &#34; http://localhost:7003/path/to/service/AccountServiceActor/getString&#34;
2 - 也取代&#39; {&#34; str&#34; :&#34;价值&#34; }&#39;与&#34; {&#34; str&#34; :&#34;价值&#34; }&#34;
答案 2 :(得分:-1)
请确保以下几点: