Integration

Get Involved. Join the Conversation.

Topic

    Lynn Dueck
    XML namespace incorrect so mapping fails
    Topic posted August 13, 2018 by Lynn DueckRed Ribbon: 250+ Points, tagged REST, xml 
    806 Views, 21 Comments
    Title:
    XML namespace incorrect so mapping fails
    Summary:
    Incoming xml payload to REST endpoint has a namespace mismatch so mapping fails
    Content:

    I have a REST endpoint configured with an xsd that declares a target namespace. A payload submitted from postman is processed successfully by ICS - all mappings produce values.

    When integrating with OMC the mappings fail to produce any values so the next step fails. When looking at the payload via ICS - activity stream it has no namespace which is why the mapping fails. I'm not sure if ICS strips the incoming namespace, or if OMC is sending a payload that doesn't align with their xsd but regardless... I need to somehow process the payload.

    I tried to remove the target namespace from the xsd that is used in configuration but ICS won't accept the xsd. Even though it validates in Oxygen, ICS complains so I assume ICS requires a target namespace in an xsd file. Not sure if this is true or not.

    I cannot create an xsd that will be accepted by ICS other than the one that fails at runtime. Are there any suggestions on how to work around this issue?

    The relevant start of the schema that is used to configure the ICS endpoint:

    <?xml version="1.0"?>
    <xs:schema elementFormDefault="qualified"
        targetNamespace="http://www.portal.com/schemas/CRMSync"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns="http://www.portal.com/schemas/CRMSync">
        <xs:element name="DiscountInfoChange">
            <xs:complexType>
                <xs:sequence>.......

    In the Test Mapper, If I generate the input based on this schema I see the following (clearly expecting the CRMSync namespace):

    INPUT

    <?xml version = '1.0' encoding = 'UTF-8'?>
    <ns0:execute xmlns:ns1="http://www.portal.com/schemas/CRMSync" xmlns:ns0="http://xmlns.oracle.com/cloud/adapter/REST/ProcessDiscountInfoChange_REQUEST_REQUEST/types">
       <ns1:DiscountInfoChange ns1:InstanceId="ns1:InstanceId14634">
          <ns1:AccountObj>AccountObj14633</ns1:AccountObj>
          <ns1:DiscountInfo>
             <ns1:Poid>Poid14635</ns1:Poid>
             <ns1:Name>Name14636</ns1:Name>
             <ns1:Code>Code14637</ns1:Code>
             <ns1:DiscountStartTime>DiscountStartTime14638</ns1:DiscountStartTime>
             <ns1:DiscountEndTime>DiscountEndTime14639</ns1:DiscountEndTime>
             <ns1:Permitted>Permitted14640</ns1:Permitted>
             <ns1:PurchaseMin>PurchaseMin14641</ns1:PurchaseMin>
             <ns1:PurchaseMax>PurchaseMax14642</ns1:PurchaseMax>
             <ns1:Priority>14643</ns1:Priority>
             <ns1:Type>14644</ns1:Type>
             <ns1:Descr>Descr14645</ns1:Descr>

          </ns1:DiscountInfo>
       </ns1:DiscountInfoChange>
    </ns0:execute>

    On execution of the mapping, this is successful:

    <?xml version = '1.0' encoding = 'UTF-8'?>
    <nstrgmpr:ProductInfoChange xmlns:svcdoc="http://xmlns.oracle.com/Services/Documentation/V1" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:nsmpr0="http://www.portal.com/schemas/CRMSync" xmlns:nstrgmpr="http://xmlns.oracle.com/EnterpriseFlows/Industry/Comms/SynchronizeProduct/V1" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:nstrgdfl="http://xmlns.oracle.com/procmon" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
       <nstrgmpr:ProductInfo>
          <nstrgmpr:ProductPoid>Poid14635 Poid14660</nstrgmpr:ProductPoid>
          <nstrgmpr:Name>Name14636 Name14661</nstrgmpr:Name>
          <nstrgmpr:Code>Code14637 Code14662</nstrgmpr:Code>
          <nstrgmpr:Type>14644 14669</nstrgmpr:Type>
          <nstrgmpr:Description>Descr14645 Descr14670</nstrgmpr:Description>
       </nstrgmpr:ProductInfo>
    </nstrgmpr:ProductInfoChange>

     

    My runtime test that fails, shows the following via the activity stream payload:

    <?xml version="1.0" encoding="UTF-8"?>
    <execute xmlns="http://xmlns.oracle.com/cloud/adapter/REST/ProcessDiscountInfoChange_REQUEST_REQUEST/types">
    <DiscountInfoChange Version="1.0" xmlns="">
        <DiscountInfo xmlns="" ElementId="0">
            <Poid xmlns="">0.0.0.1 /discount 326190 1</Poid>
            <Permitted xmlns="">/service/cloud/entertainment</Permitted>
            <Name xmlns="">A2 discount</Name>
            <Descr xmlns="">A2 DiscountOffer - that is what this is</Descr>
            <DiscountStartTime xmlns="">Wed Dec 31 16:00:00 PST 1969</DiscountStartTime>
            <DiscountEndTime xmlns="">Wed Dec 31 16:00:00 PST 1969</DiscountEndTime>
            <Priority xmlns="">10</Priority>
            <Type xmlns="">602</Type>
            <Code xmlns="">ef8f2772-eb1b-487d-a807-2d4b5676b97e</Code>
            <UsageMap xmlns="" ElementId="0">
                <EventType xmlns="">/event/billing/product/fee/cycle/cycle_forward_monthly</EventType>
            </UsageMap>
        </DiscountInfo>
    </DiscountInfoChange>
    </execute>

    No namespace is provided and so of course produces empty values for the mapping.

    Is there anyway to alter my schema so that there is no namespace declared and therefore expected by ICS?

     

    Comment

     

    • Jorge Herreria

       

      # Do/Try Why
      1

      In your XSD:

      <xs:schema elementFormDefault="unqualified" attributeFormDefault="unqualified"

      Define the schema to be unqualified (elements do not need a namespace). Be aware the Root Element always have a namespace regardless what the elementFormDefault  says. To be sure, lets explicitly declare the same for attributes.
      2

      In the XSL (Map)

      <nssrcmp:execute>

         <DiscountInfoChange InstanceId="InstanceId14634">

      The Target root element (execute) must have a prefix referencing the "http://www.portal.com/schemas/CRMSync" namespace.

      The rest of the elements does not need to have a prefix.  The OIC/ICS Map editor will take care of creating the prefix where needed based on the schema definition

           

       

       

       

       

       

       

       

       

       

       

       

      • Lynn Dueck

        Changing the schema to unqualified has no effect on the behavior and there is no way in the mapper to add a namespace declaration. 

        I have tried numerous things to work around this and it seems to me that ICS is putting in a null namespace on every node. xmlns="" is not in the payload I am sending but it does appear on each element in the ICS payload. (See comment below this one)

    • Hemanth Lakkaraju

      Is this on ICS or OIC?

      <DiscountInfoChange Version="1.0" xmlns="">

      It is evident from the payload that runtime request doesn't have the namespace. Can you check why the runtime request doesn't have namespace unlike the schema which is used? Isn't the schema from the target system?

      • Lynn Dueck

        This is ICS.

        It appears to me that ICS is adding the empty namespace. If I submit a payload from postman that does NOT include a namespace...when I look at what is logged in the activity stream then the empty namespace is added.

        postman:

        <?xml version="1.0" encoding="UTF-8"?>
        <DiscountInfoChange Version="1.0">
            <DiscountInfo>
                <Poid>0.0.0.1 /discount 326190 1</Poid>
                <Permitted>/service/cloud/entertainment</Permitted>
                <Name>A2 discount</Name>
                <Descr>A2 DiscountOffer - that is what this is</Descr>
                <DiscountStartTime>Wed Dec 31 16:00:00 PST 1969</DiscountStartTime>
                <DiscountEndTime>Wed Dec 31 16:00:00 PST 1969</DiscountEndTime>
                <Priority>10</Priority>
                <Type>602</Type>
                <Code>ef8f2772-eb1b-487d-a807-2d4b5676b97e</Code>
            </DiscountInfo>
        </DiscountInfoChange>

         

        ICS activity stream payload:

        Request sent to Test<execute xmlns="http://xmlns.oracle.com/cloud/adapter/REST/Test_REQUEST/types"><DiscountInfoChange xmlns="" Version="1.0">    <DiscountInfo xmlns="">        <Poid xmlns="">0.0.0.1 /discount 326190 1</Poid>        <Permitted xmlns="">/service/cloud/entertainment</Permitted>        <Name xmlns="">A2 discount</Name>        <Descr xmlns="">A2 DiscountOffer - that is what this is</Descr>        <DiscountStartTime xmlns="">Wed Dec 31 16:00:00 PST 1969</DiscountStartTime>        <DiscountEndTime xmlns="">Wed Dec 31 16:00:00 PST 1969</DiscountEndTime>        <Priority xmlns="">10</Priority>        <Type xmlns="">602</Type>        <Code xmlns="">ef8f2772-eb1b-487d-a807-2d4b5676b97e</Code>    </DiscountInfo></DiscountInfoChange><HTTPHeaders/></execute>

        • Hemanth Lakkaraju

          That is true. The xml from postman doesn't have any namespace which means the namespace is empty (xmlns-=""). If the original xml doesn't have namespace, why was REST adapter configured with namespace? Is it JUST because REST adapter is not allowing schema upload without namespace or is there any other reason?

          • Lynn Dueck

            Originally the schema from the external system I was given had a namespace. But...it was out of date and there is actually no namespace used.

            I then attempted to re-configure the endpoint with the updated schema but ICS prevents me from uploading a schema without a target namespace. I'm lost as to how I'm supposed to configure this properly.

             

          • Lynn Dueck

            Does ICS enforce xml schema to define a target namespace?

            If so, how is integration with an external system that doesn't use a namespace supposed to work?

    • Jorge Herreria

      Can you export your Orchestration and upload the IAR here? Also the XSD you are using?

      I would like to take a look the generated metadata/code by ICS

      • Lynn Dueck

        In the attached zip file, is the IAR as well as 2 schemas.

        The one "xxx_ICSaccepts.xsd" is the original one I used which has the target namespace included. This one does not work at runtime because in actual fact the external system does not use a namespace.

        The one "xxx_NoNamespace.xsd" is the same schema without a target namespace. This is the one I should really be using but ICS prevents me from uploading into the endpoint configuration.

        temp.zip (12KB)
    • Jorge Herreria

      2 more tries. Then if none works, please create a Service Request. If one works, please let me know as well because it means we found a bug.

      Try 1

      Use the attached schema in your adapter definition.  I added  the targetNamespace declaration which is needed even if the elementFormDefault is unqualidied (default)

      Use the attached XSLT: In the  Map To InputCPQ Pr... use context menu to import it.

      Try 2

      To eliminate "noise" create the orchestration from scratch, use the attached XSD and XSLT

       

      Explanation on XSLT change:

      Before notice the prefix:  nsmpr0 Changed to no prefix
      <!--User Editing allowed BELOW this line - DO NOT DELETE THIS LINE-->
      <xsl:template match="/" xml:id="id_11">
         <nstrgmpr:ProductInfoChange xml:id="id_12">
            
         <nstrgmpr:ProductInfo xml:id="id_37">
               <nstrgmpr:ProductPoid xml:id="id_38">
                  <xsl:value-of select="/nssrcmpr:execute/nsmpr0:DiscountInfoChange/nsmpr0:DiscountInfo/nsmpr0:Poid" xml:id="id_39"/>
               </nstrgmpr:ProductPoid>
               <nstrgmpr:Name xml:id="id_40">
                  <xsl:value-of select="/nssrcmpr:execute/nsmpr0:DiscountInfoChange/nsmpr0:DiscountInfo/nsmpr0:Name" xml:id="id_41"/>
               </nstrgmpr:Name>
               <nstrgmpr:Code xml:id="id_42">
                  <xsl:value-of select="/nssrcmpr:execute/nsmpr0:DiscountInfoChange/nsmpr0:DiscountInfo/nsmpr0:Code" xml:id="id_43"/>
               </nstrgmpr:Code>
               <nstrgmpr:Type xml:id="id_46">
                  <xsl:value-of select="/nssrcmpr:execute/nsmpr0:DiscountInfoChange/nsmpr0:DiscountInfo/nsmpr0:Type" xml:id="id_47"/>
               </nstrgmpr:Type>
               <nstrgmpr:Description xml:id="id_44">
                  <xsl:value-of select="/nssrcmpr:execute/nsmpr0:DiscountInfoChange/nsmpr0:DiscountInfo/nsmpr0:Descr" xml:id="id_45"/>
               </nstrgmpr:Description>
            </nstrgmpr:ProductInfo>
         </nstrgmpr:ProductInfoChange>
      </xsl:template>
      
      <!--User Editing allowed BELOW this line - DO NOT DELETE THIS LINE-->
      <xsl:template match="/" xml:id="id_11">
         <nstrgmpr:ProductInfoChange xml:id="id_12">
            
         <nstrgmpr:ProductInfo xml:id="id_37">
               <nstrgmpr:ProductPoid xml:id="id_38">
                  <xsl:value-of select="/nssrcmpr:execute/DiscountInfoChange/DiscountInfo/Poid" xml:id="id_39"/>
               </nstrgmpr:ProductPoid>
               <nstrgmpr:Name xml:id="id_40">
                  <xsl:value-of select="/nssrcmpr:execute/DiscountInfoChange/DiscountInfo/Name" xml:id="id_41"/>
               </nstrgmpr:Name>
               <nstrgmpr:Code xml:id="id_42">
                  <xsl:value-of select="/nssrcmpr:execute/DiscountInfoChange/DiscountInfo/Code" xml:id="id_43"/>
               </nstrgmpr:Code>
               <nstrgmpr:Type xml:id="id_46">
                  <xsl:value-of select="/nssrcmpr:execute/DiscountInfoChange/DiscountInfo/Type" xml:id="id_47"/>
               </nstrgmpr:Type>
               <nstrgmpr:Description xml:id="id_44">
                  <xsl:value-of select="/nssrcmpr:execute/DiscountInfoChange/DiscountInfo/Descr" xml:id="id_45"/>
               </nstrgmpr:Description>
            </nstrgmpr:ProductInfo>
         </nstrgmpr:ProductInfoChange>
      </xsl:template>
      

       

      Please let me know your findings!

       

      
       
      

       

    • Jorge Herreria

      ehem! Maybe I did the map wrong. Here's another version. Please try w/this one.

      Notice nsmpr0 goes in the first "execute" child

      <nstrgmpr:ProductInfo xml:id="id_37">
            <nstrgmpr:ProductPoid xml:id="id_38">
               <xsl:value-of select="/nssrcmpr:execute/nsmpr0:DiscountInfoChange/DiscountInfo/Poid" xml:id="id_39"/>
            </nstrgmpr:ProductPoid>
            <nstrgmpr:Name xml:id="id_40">
               <xsl:value-of select="/nssrcmpr:execute/nsmpr0:DiscountInfoChange/DiscountInfo/Name" xml:id="id_41"/>
            </nstrgmpr:Name>
            <nstrgmpr:Code xml:id="id_42">
               <xsl:value-of select="/nssrcmpr:execute/nsmpr0:DiscountInfoChange/DiscountInfo/Code" xml:id="id_43"/>
            </nstrgmpr:Code>
            <nstrgmpr:Type xml:id="id_46">
               <xsl:value-of select="/nssrcmpr:execute/nsmpr0:DiscountInfoChange/DiscountInfo/Type" xml:id="id_47"/>
            </nstrgmpr:Type>
            <nstrgmpr:Description xml:id="id_44">
               <xsl:value-of select="/nssrcmpr:execute/nsmpr0:DiscountInfoChange/DiscountInfo/Descr" xml:id="id_45"/>
            </nstrgmpr:Description>
         </nstrgmpr:ProductInfo>
      

       

      MapV2.xsl (4KB)
      • Lynn Dueck

        ICS wouldn't accept the schema as you had it. attached is an image of the error message. 

        I edited it to add xmlns="http://www.portal.com/schemas/CRMSync". I'm not sure if this will affect the test or not but worth a try.

        I don't know how to upload the xsl you have provided. If I open my mapping, I don't see an option for importing anywhere. 

        Could you possibly provide a screen shot of where the context menu is?

        thanks!

         

    • Jorge Herreria

       xmlns="http://www.portal.com/schemas/CRMSync" is most likely needed... Glad you found adding it will make the XSD valid.

       

      To import the XSLT, do right click on the Map Icon/image. Instead of clicking to enter the editor, do right click. Right there you'll find Import and Delete options.... Be aware that after importing the XSLT you will be not allowed to go into the Map editor for that Map activity. That is expected behavior...

      If the whole idea works, then it will tell me there is a bug in the Map editor and you'll have a way to keep working by importing the Maps... 

      • Lynn Dueck

        The import failed with the following message:

        "The specification map sources and targets is incorrect. Please ensure the oracle-xsl-mapper:schema section in the map file being imported is exactly the same as the previously exported map file."

        • Jorge Herreria

          What a bad lock! You are hitting an existing bug. Dev team is currently working on the fix....

          The ugly work around: Please create a brand new orchestration and try there...

          The bug is that once the orchestration is activated, the import map starts failing giving that error that you just saw....

          • Lynn Dueck

            Was off on PTO so didn't have a chance to do this before I left.

            I created a brand new integration, supplied the namespace aware xml schema and instead of doing any mapping, just tried to import the MapV2.xsl.

            Unfortunately even in a brand new integration I get the same error on import "The specification of map sources and targets is incorrect....."

            • Jorge Herreria

              Grrr: Importing an XSLT from one orchestration to another is not valid.

              You'll need to redo the mapping in the XSLT for this orchestration.

              Here's how to open the XSLT in JDeveloper then how to import it.

              https://docs.oracle.com/en/cloud/paas/integration-cloud/integrations-user/mapping-integration-cloud-service-data.html#GUID-A8921EBF-28D6-4E70-BBEB-577ECE8019B2

    • Lynn Dueck

      Thanks - I'll give that a try and let you know.

      Just to confirm something that really hasn't been answered...is it true that ICS requires an xml schema to have a target namespace declared?

      And if so, then what is the strategy for systems that don't use a namespace? Would it be the recomendation to NOT use schema and use JSON instead?

       

      • Jorge Herreria

        If you can change your service to be JSON go for it.  XML Qualified Schemas and JSON is way more used "content formats" in ICS Orchestrations than Unqualified schemas... So if you can make it XML Qualified or JSON, then you'll be hitting proven/used code.

        In theory unqualified schemas are supported in ICS. Obviously there is a bug somewhere that you are experiencing and I'm trying with your help to flush out.

        I would need to investigate more if ICS requires the target namespace declared for unqualified schemas... 

        For now I want to give you the option to keep working by using JSON or qualified schemas...

        • Lynn Dueck

          I've been able to reconfigure the payload coming from the external system to be JSON, so I'll use that for now.

          Thanks for your help,