NahidAfzali opened a new issue, #9314:
URL: https://github.com/apache/apisix/issues/9314
### Current Behavior
Hi, I'm using the body transformer plugin to change my soap API. I have
tried lots of ways for changing the template, but every time I've got errors
and even my API didn't invoke. Please help how can I change the template to
achieve a successful response.
Thank you in advance,
here is my data:
{
"uri": "/VIPC/InquiryNationalCode2",
"name": "InquiryNationalCode2",
"plugins": {
"body-transformer": {
"request": {
"template": "<?xml version=\"1.0\"?>\n<soap-env:Envelope
xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\">\n
<soap-env:Body>\n <ns0:InquiryNationalCode
xmlns:ns0=\"http://tempuri.org\">\n
<ns0:inquiryNationalCodeRequest>\n
<ns0:RequestNumber>{{_escape_xml(RequestNumber)}}</ns0:RequestNumber>\n
<ns0:sessionId>{{_escape_xml(sessionId)}}</ns0:sessionId>\n
<ns0:mac>{{_escape_xml(mac)}}</ns0:mac>\n
<ns0:Ip>{{_escape_xml(Ip)}}</ns0:Ip>\n
<ns0:NationalId>{{_escape_xml(NationalId)}}</ns0:NationalId>\n
<ns0:BirthDate>{{_escape_xml(BirthDate)}}</ns0:BirthDate>\n
</ns0:inquiryNationalCodeRequest>\n </ns0:InquiryNationalCode>\n
</soap-env:Body>\n</soap-env:Envelope>"
},
"response": {
"template": "{% if Envelope.Body.Fault == nil then
%}\n{\"Result\":\"{{Envelope.Body.InquiryNationalCodeResponse.InquiryNationalCodeResult.Result}}\"}\n{%
else
%}{\"message\":{*_escape_json(Envelope.Body.Fault.faultstring[1])*},\n\"code\":\"{{Envelope.Body.Fault.faultcode}}\"\n{%
if Envelope.Body.Fault.faultactor ~= nil then %},\n
\"actor\":\"{{Envelope.Body.Fault.faultactor}}\"\n {% end %}}{% end %}"
}
},
"proxy-rewrite": {
"uri": "/service.asmx?op=InquiryNationalCode",
"use_real_request_uri_unsafe": false
},
"response-rewrite": {
"body_base64": false,
"headers": {
"set": {
"Content-Type": "application/json"
}
}
}
},
"upstream_id": "455796621209240261",
"labels": {
"API_VERSION": "V1"
},
"status": 1
}
### Expected Behavior
Success response
### Error Logs
2023/04/15 15:30:03 [warn] 50#50: *17998910 [lua] plugin.lua:929:
encrypt_conf(): failed to get schema for plugin: body-transformer, client:
10.0.84.150, server: , request: "PUT /apisix/admin/routes/test_2 HTTP/1.1",
host: "10.0.84.150:9180"
2023/04/15 15:30:03 [warn] 50#50: *17998910 [lua] plugin.lua:929:
encrypt_conf(): failed to get schema for plugin: proxy-rewrite, client:
10.0.84.150, server: , request: "PUT /apisix/admin/routes/test_2 HTTP/1.1",
host: "10.0.84.150:9180"
10.0.84.150 - - [15/Apr/2023:15:30:03 +0000] 10.0.84.150:9180 "PUT
/apisix/admin/routes/test_2 HTTP/1.1" 201 1665 0.016 "-" "curl/7.29.0" - - -
"http://10.0.84.150:9180"
2023/04/15 15:30:09 [error] 50#50: *17999135 [lua] body-transformer.lua:145:
transform(): response template rendering: [string "context=... or {}..."]:5:
attempt to index global 'Envelope' (a nil value) while sending to client,
client: 10.0.204.72, server: _, request: "POST /VIPC/InquiryNationalCode2
HTTP/1.1", upstream:
"http://10.0.85.53:80/service.asmx?op=InquiryNationalCode", host:
"10.0.84.150:9080"
2023/04/15 15:30:09 [error] 50#50: *17999135 [lua] body-transformer.lua:202:
phase_func(): failed to transform response body: <?xml version="1.0"
encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Unable
to handle request without a valid action parameter. Please supply a valid soap
action.</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope> while
sending to client, client: 10.0.204.72, server: _, request: "POST
/VIPC/InquiryNationalCode2 HTTP/1.1", upstream:
"http://10.0.85.53:80/service.asmx?op=InquiryNationalCode", host:
"10.0.84.150:9080"
10.0.204.72 - - [15/Apr/2023:15:30:09 +0000] 10.0.84.150:9080 "POST
/VIPC/InquiryNationalCode2 HTTP/1.1" 500 5 0.011 "-" "PostmanRuntime/7.31.0"
10.0.85.53:80 500 0.011
"http://10.0.84.150:9080/service.asmx?op=InquiryNationalCode"
2023/04/15 15:35:34 [warn] 50#50: *18012295 [lua] plugin.lua:929:
encrypt_conf(): failed to get schema for plugin: body-transformer, client:
10.0.84.150, server: , request: "PUT /apisix/admin/routes/test_2 HTTP/1.1",
host: "10.0.84.150:9180"
2023/04/15 15:35:34 [warn] 50#50: *18012295 [lua] plugin.lua:929:
encrypt_conf(): failed to get schema for plugin: proxy-rewrite, client:
10.0.84.150, server: , request: "PUT /apisix/admin/routes/test_2 HTTP/1.1",
host: "10.0.84.150:9180"
10.0.84.150 - - [15/Apr/2023:15:35:34 +0000] 10.0.84.150:9180 "PUT
/apisix/admin/routes/test_2 HTTP/1.1" 201 1665 0.017 "-" "curl/7.29.0" - - -
"http://10.0.84.150:9180"
2023/04/15 15:35:45 [error] 50#50: *18012722 [lua] body-transformer.lua:145:
transform(): response template rendering: [string "context=... or {}..."]:5:
attempt to index global 'Envelope' (a nil value) while sending to client,
client: 10.0.204.72, server: _, request: "POST /VIPC/InquiryNationalCode2
HTTP/1.1", upstream:
"http://10.0.85.53:80/service.asmx?op=InquiryNationalCode", host:
"10.0.84.150:9080"
2023/04/15 15:35:45 [error] 50#50: *18012722 [lua] body-transformer.lua:202:
phase_func(): failed to transform response body: <?xml version="1.0"
encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Unable
to handle request without a valid action parameter. Please supply a valid soap
action.</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope> while
sending to client, client: 10.0.204.72, server: _, request: "POST
/VIPC/InquiryNationalCode2 HTTP/1.1", upstream:
"http://10.0.85.53:80/service.asmx?op=InquiryNationalCode", host:
"10.0.84.150:9080"
10.0.204.72 - - [15/Apr/2023:15:35:45 +0000] 10.0.84.150:9080 "POST
/VIPC/InquiryNationalCode2 HTTP/1.1" 500 5 0.005 "-" "PostmanRuntime/7.31.0"
10.0.85.53:80 500 0.005
"http://10.0.84.150:9080/service.asmx?op=InquiryNationalCode"
### Steps to Reproduce
Run APISIX via Docker image
### Environment
- APISIX version (run `apisix version`):
- Operating system (run `uname -a`):
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
- etcd version, if relevant (run `curl
http://127.0.0.1:9090/v1/server_info`):
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]