API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#API Connect
#Applicationintegration
#APIConnect
 View Only
  • 1.  Difference in xml response

    Posted Wed December 29, 2021 05:14 AM
    Hello Team,

    When we are hitting the api from target url we are getting proper xml response and when we are hitting with api url we are getting "&lt" characters in it.
    expected output should be same as target url.



    Thanks and Regards

    ------------------------------
    Pawan Jinaga
    ------------------------------


  • 2.  RE: Difference in xml response

    Posted Thu December 30, 2021 03:41 AM

    Dear Pawan,

     Would it be the case that the target service doesn't return the proper content-type header ("application/xml")?

    I would expect that APIC honours content type and not to escape HTML characters in output if 

    content-type is correct.

    Also, please make sure you don't set the wrong content type in APIC assembly as well. 

    BR,
    Miro



    ------------------------------
    Miroslav Rešetar
    CROZ d.o.o.
    Zagreb
    ------------------------------



  • 3.  RE: Difference in xml response

    Posted Thu December 30, 2021 06:33 AM
    Hello sir,

    The content type of target url's(Client site) response is in "text/xml;charset utf-8" ,
    and content type of Api url's response is in "text/xml" 
    after that even if we are changing the content type to "text/xml;charset utf-8" we are getting the same difference.

    Thanks and Regards,



    ------------------------------
    Pawan Jinaga
    ------------------------------



  • 4.  RE: Difference in xml response

    Posted Thu December 30, 2021 08:45 AM

    I've tried to reproduce the issue.

    Created 2 responses: 

     - valid: curl -s https://mockbin.org/bin/c1a010ee-02d7-4acc-aec0-1a4171a17f90, returnes <some>valid xml</some>

     - invalid: curl -s https://mockbin.org/bin/9dba60ac-9596-49c1-941a-430eef916f32, returnes <some>invalid<id> xml</some>

    For both, I've created simple APIC proxies (Open API v3, APIC 10.0.4.0) and responses are identical to the ones returned by those 2 endpoints. 

    Sorry, I can't help more. I don't experience that APIC is escaping HTML chars. 

    BR,
    Miro



    ------------------------------
    Miroslav Rešetar
    CROZ d.o.o.
    Zagreb
    ------------------------------



  • 5.  RE: Difference in xml response

    Posted Tue January 04, 2022 09:14 AM

    Hi Pawan,

    What version of API Connect are you using.  In v5 (or in v10 with a v5 compatible gateway), the results from an invoke policy will be implicitly parsed.  If you have a response with a CDATA section, the any < character will be escaped to a &lt;  I'm not sure if there is a mechanism to add the CDATA back to your xml.  Perhaps a complex post response gateway extension rule to look for your specific response and run a  xslt stylesheet against it to place the CDATA back using the xsl:output element with the cdata-section-elements attribute to specify the element that should contain the CDATA section, but I've never tried it myself to verify if it works.  If you're using v10, then v10 does not parse the invoke policy response implicitly, so if you are using a parse policy to extract some data from the XML for some purpose, then parse it to a context other than message (the default for the parse policy) and operate on that context's body.

    Regards,

    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------