sanjivkamate commented on issue #9911:
URL: https://github.com/apache/apisix/issues/9911#issuecomment-1652971159

   > > > @sanjivkamate Will you try adding the field `"input_format":"xml"` 
explicitly in conf? Also while getting response over APISIX, when you dont use 
body transform plugin, do you get normal xml response?
   > > 
   > > 
   > > @Revolyssup Tried with "input_format":"xml" like below, same response in 
the error log as before "response": { "input_format":"xml", "template": "{% if 
Envelope.Body.Fault == nil then 
%}{"currency":"{{Envelope.Body.AddResponse.AddResult}}"}{% else 
%}{"message":{__escape_json(Envelope.Body.Fault.faultstring[1])_},"code":"{{Envelope.Body.Fault.faultcode}}"{%
 if Envelope.Body.Fault.faultactor ~= nil then %}, 
"actor":"{{Envelope.Body.Fault.faultactor}}"{% end %}}{% end %}" }
   > > **Also while getting response over APISIX, when you dont use body 
transform plugin, do you get normal xml response?** @Revolyssup I am not sure 
how to try this as the reason I am using body transform plugin is to read my 
XML response which is SOAP based.
   > > **Also when you just use the request template and not response template, 
do you get proper xml response?** @Revolyssup No error is being logged in 
error.log, getting 200 response but response is empty.
   > > Thank you for the response.
   > 
   > The default priority of response-rewrite> body-transform where you set the 
content-type to json. Please remove the response-rewrite plugin and try again
   
   @Revolyssup  Please ignore,  I changed  Accept-Encoding from 
"Accept-Encoding": "gzip, deflate, br"  to"Accept-Encoding": "identity" and it 
is working fine now. I am getting valid response.
   Thank you for spending time in checking and responding.
   
   **The final working config is**
   
   curl http://127.0.0.1:9180/apisix/admin/routes/test_ws -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "methods": ["POST"],
       "uri": "/calculator.asmx",
       "plugins": {
           "proxy-rewrite": {
                "host": "dneonline.com",
                "use_real_request_uri_unsafe": false,
               "headers": {
                   "set": {
                       "Accept-Encoding": "identity",
                       "Content-Type": "text/xml",
                       "SOAPAction":"http://tempuri.org/Add";
                   }
               }
           },
           "response-rewrite": {
               "body_base64": false,
               "headers": {
                   "set": {
                       "Content-Type": "application/json"
                   }
               }
           },
           "body-transformer": {
               "request": {
                   "template": "<?xml version=\"1.0\"?><soapenv:Envelope 
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"; 
xmlns:tem=\"http://tempuri.org/\";><soapenv:Header/><soapenv:Body><tem:Add><tem:intA>{{_escape_xml(add1)}}</tem:intA><tem:intB>{{_escape_xml(add2)}}</tem:intB></tem:Add></soapenv:Body></soapenv:Envelope>"
               },
               "response": {
                        "input_format":"xml",
                   "template": "{% if Envelope.Body.Fault == nil then 
%}{\"currency\":\"{{Envelope.Body.AddResponse.AddResult}}\"}{% else 
%}{\"message\":{*_escape_json(Envelope.Body.Fault.faultstring[1])*},\"code\":\"{{Envelope.Body.Fault.faultcode}}\"{%
 if Envelope.Body.Fault.faultactor ~= nil then %}, 
\"actor\":\"{{Envelope.Body.Fault.faultactor}}\"{% end %}}{% end %}"
               }
           }
       },
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "www.dneonline.com:80": 1
           }
       }
   }'


-- 
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]

Reply via email to