You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "NahidAfzali (via GitHub)" <gi...@apache.org> on 2023/04/16 04:38:03 UTC

[GitHub] [apisix] NahidAfzali opened a new issue, #9314: bug: Error 500 in body transformer plugin for transforming soap API to rest

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: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] AlinsRan closed issue #9314: bug: Error 500 in body transformer plugin for transforming soap API to rest

Posted by "AlinsRan (via GitHub)" <gi...@apache.org>.
AlinsRan closed issue #9314: bug: Error 500 in body transformer plugin for transforming soap API to rest
URL: https://github.com/apache/apisix/issues/9314


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] Sn0rt commented on issue #9314: bug: Error 500 in body transformer plugin for transforming soap API to rest

Posted by "Sn0rt (via GitHub)" <gi...@apache.org>.
Sn0rt commented on issue #9314:
URL: https://github.com/apache/apisix/issues/9314#issuecomment-1649333763

   @NahidAfzali hi can you provider the step for reproduce ?
   
   if I not get your reply I will close this issue after one week.


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] shreemaan-abhishek commented on issue #9314: bug: Error 500 in body transformer plugin for transforming soap API to rest

Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on issue #9314:
URL: https://github.com/apache/apisix/issues/9314#issuecomment-1511193936

   Essentially, this isn't a bug, is it?


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] NahidAfzali commented on issue #9314: bug: Error 500 in body transformer plugin for transforming soap API to rest

Posted by "NahidAfzali (via GitHub)" <gi...@apache.org>.
NahidAfzali commented on issue #9314:
URL: https://github.com/apache/apisix/issues/9314#issuecomment-1510053968

   I also want to mention that there is no more sample for the template, and that's not good for your product. This plugin is really important and should have more samples and documents.


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] kingluo commented on issue #9314: bug: Error 500 in body transformer plugin for transforming soap API to rest

Posted by "kingluo (via GitHub)" <gi...@apache.org>.
kingluo commented on issue #9314:
URL: https://github.com/apache/apisix/issues/9314#issuecomment-1554765268

   > I also want to mention that there is no more sample for the template, and that's not good for your product. This plugin is really important and should have more samples and documents.
   
   @NahidAfzali Hi, it seems that your response is not a valid XML text.
   
   Could you paste your route configuration and error log in the markdown code block so that I could verify them?


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org