cancel
Showing results for 
Search instead for 
Did you mean: 

to read an XML in PI without ns1: tag

former_member1330829
Participant
0 Kudos

Hi experts,

I have an inbound XML file from a third party which PI is supposed to read and validate.

when the sender channel picks up the file it throws the error:

Error:
com.sap.engine.interfaces.messaging.api.exception.MessageFormatException: XML
Validation for payload with root element name ConfigRequests , target namespace
Failed!Errors Encountered During Parsing 1.cvc-elt.1: Cannot find the
declaration of element 'ConfigRequests'.

i  have tried processing he same file with ns1: and it passes successfully in PI

Can PI read an XML without the "ns1" tag.

Accepted Solutions (0)

Answers (3)

Answers (3)

udo_martens
Active Contributor
0 Kudos

Hi Tanzoom,

'ns1' is not a tag but a namespace prefix. It stands for a namespace and is part of the identity of an xml element. ConfigRequests was simply not validated because it was not in the right namespace. Which prefix you use, doesnt matter. Only the represented value - the namespace - is important.

/Udo

iaki_vila
Active Contributor
0 Kudos

Hi Tanzoom,

The best way is the pointed out by Javier. You can also use a XSL mapping to remove all the namespaces, check my answer in this thread

Regards.

javier_alcubilla
Contributor
0 Kudos

Hi Tanzoom

Check this blog

Regards

Javi

former_member1330829
Participant
0 Kudos

Hi Javier,

Can the Anonymizer bean be used to add the namespace in the above incoming XML in PI (as it doesnot have any) and then remove it (using the bean)after being processed in PI.

Or

How do we go ahed with the Anonymizer bean incase the XML doesnot have any namespace.

javier_alcubilla
Contributor
0 Kudos

try this

Module Name:AF_Modules/XMLAnonymizerBean

Type: Local Enterprise Bean

Module Key: 0

Module configuration

Module Key 0


Parameter Name :  anonymizer.acceptNamespaces

Parameter Value: '' ns1

former_member1330829
Participant
0 Kudos

Hi Javier,

On using this my channel throws the below error:

Error:
com.sap.engine.interfaces.messaging.api.exception.MessagingException: The prefix
"ns1" for element "ns1:ConfigRequests" is not bound.
javier_alcubilla
Contributor
0 Kudos

Could you attach the structure desired and the actual one?

former_member1330829
Participant
0 Kudos

Hi Javier,

My sturcture looks like below. Both the source an Target is same , as i just need to validate (schema validation) the source XML in PI and pass it on

<?xml version="1.0" standalone="yes"?><ConfigRequests ParticipantID="ABC">

<ConfigRequest>

  <MpanMprn>123</MpanMprn>

  <MeterSerialNumber>METER5</MeterSerialNumber>

  <Configs>

   <TariffConfig>

    <SetTariff>

     <fromTariffRef>R1</fromTariffRef>

     <toTariffRef>R2</toTariffRef>

     <effectiveDate>2011-09-09</effectiveDate>

    </SetTariff>

   </TariffConfig>

  </Configs>

</ConfigRequest>

<ConfigRequest>

  <MpanMprn>220</MpanMprn>

  <MeterSerialNumber>D13A011524</MeterSerialNumber>

  <Configs>

   <TariffConfig>

    <SetTariff>

     <fromTariffRef>OLDTAR1</fromTariffRef>

     <toTariffRef>NEWTAR2</toTariffRef>

     <effectiveDate>2014-09-17</effectiveDate>

    </SetTariff>

   </TariffConfig>

  </Configs>

</ConfigRequest>

</ConfigRequests>

Since the structure doesnot have the ns1: tag, the channel throws the below error while XSD validation

MP: exception caught with cause
com.sap.engine.interfaces.messaging.api.exception.MessageFormatException: XML
Validation for payload with root element name ConfigRequests , target namespace
Failed!Errors Encountered During Parsing 1.cvc-elt.1: Cannot find the
declaration of element 'ConfigRequests'.

javier_alcubilla
Contributor
0 Kudos

And the file that has to be picked?

former_member1330829
Participant
0 Kudos

Yes, The file has to be picked by PI, check for all the mandatory fields i.e schema validate it and pass on as it is

javier_alcubilla
Contributor
0 Kudos

ok. i want to see the file content, to check for namespaces or something that raise your error

former_member1330829
Participant
0 Kudos

the file copied above is the Actual file , without any name space

<?xml version="1.0" standalone="yes"?><ConfigRequests ParticipantID="ABC">

<ConfigRequest>

  <MpanMprn>123</MpanMprn>

  <MeterSerialNumber>METER5</MeterSerialNumber>

  <Configs>

   <TariffConfig>

    <SetTariff>

     <fromTariffRef>R1</fromTariffRef>

     <toTariffRef>R2</toTariffRef>

     <effectiveDate>2011-09-09</effectiveDate>

    </SetTariff>

   </TariffConfig>

  </Configs>

</ConfigRequest>

<ConfigRequest>

  <MpanMprn>220</MpanMprn>

  <MeterSerialNumber>D13A011524</MeterSerialNumber>

  <Configs>

   <TariffConfig>

    <SetTariff>

     <fromTariffRef>OLDTAR1</fromTariffRef>

     <toTariffRef>NEWTAR2</toTariffRef>

     <effectiveDate>2014-09-17</effectiveDate>

    </SetTariff>

   </TariffConfig>

  </Configs>

</ConfigRequest>

</ConfigRequests>

javier_alcubilla
Contributor
0 Kudos

Have you checked you XML Namespace in your message type?

Empty that field and try again

former_member1330829
Participant
0 Kudos

My external Definition doesnot have any namespace in it. Below is the schema

<?xml version="1.0" encoding="utf-8"?>

<!--Created with Liquid XML Studio Designer Edition 8.1.2.2399 (http://www.liquid-technologies.com)-->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

<xs:element name="ConfigRequests">

  <xs:complexType>

   <xs:sequence>

    <xs:element name="ConfigRequest" maxOccurs="unbounded">

     <xs:complexType>

      <xs:sequence>

       <xs:element name="MpanMprn" minOccurs="1" maxOccurs="1">

        <xs:simpleType>

         <xs:restriction base="xs:string">

          <xs:maxLength value="13"/>

         </xs:restriction>

        </xs:simpleType>

       </xs:element>

       <xs:element name="MeterSerialNumber" minOccurs="1">

        <xs:simpleType>

         <xs:restriction base="xs:string">

          <xs:maxLength value="30"/>

         </xs:restriction>

        </xs:simpleType>

       </xs:element>

       <xs:element name="Configs">

        <xs:complexType>

         <xs:sequence>

          <xs:element name="NonDisconnectMeterConfig" minOccurs="0" maxOccurs="unbounded">

           <xs:complexType>

            <xs:sequence>

             <xs:element name="NonDisconnectConfigID" minOccurs="1" maxOccurs="1">

              <!--<xs:annotation>

               <xs:documentation xml:lang="EN">This is the

                period identifier that is defined by the supplier in the

                NonDisconnectConfig XML file. This will map to an

                internal Instant Energy identifier, but the

                customer/supplier does not need to know what our

                internal number is.</xs:documentation>

              </xs:annotation>-->

              <xs:complexType>

               <xs:simpleContent>

                <xs:extension base="xs:string"/>

               </xs:simpleContent>

              </xs:complexType>

             </xs:element>

             <xs:element name="effectiveDate" type="xs:date" minOccurs="1" maxOccurs="1"/>

            </xs:sequence>

           </xs:complexType>

          </xs:element>

          <xs:element name="HolidayMeterConfig" minOccurs="0" maxOccurs="unbounded">

           <xs:complexType>

            <xs:sequence>

             <xs:element name="HolidayConfigID" minOccurs="1" maxOccurs="1">

              <!--<xs:annotation>

               <xs:documentation xml:lang="EN">This is the

                holiday identifier that is defined by the supplier in

                the HolidayConfig XML file. This will map to an internal

                Instant Energy identifier, but the customer/supplier

                does not need to know what our internal number is.

               </xs:documentation>

              </xs:annotation>-->

              <xs:complexType>

               <xs:simpleContent>

                <xs:extension base="xs:string"/>

               </xs:simpleContent>

              </xs:complexType>

             </xs:element>

             <xs:element name="effectiveDate" type="xs:date" minOccurs="1" maxOccurs="1"/>

            </xs:sequence>

           </xs:complexType>

          </xs:element>

          <xs:element name="TariffConfig" minOccurs="0" maxOccurs="unbounded">

           <xs:complexType>

            <xs:choice>

             <xs:element name="SetTariff">

              <!--<xs:annotation>

               <xs:documentation xml:lang="EN">This is the 'Set Tariff' option for the tariff configuration. This will allow the tariff on a meter to be changed from one tarrif ID to anther tariff ID.</xs:documentation>

              </xs:annotation>-->

              <xs:complexType>

               <xs:sequence>

                <xs:element name="fromTariffRef" minOccurs="1" maxOccurs="1">

                 <!--<xs:annotation>

                  <xs:documentation xml:lang="EN">This is the expected existing tariff ID on the meter that will be validated against and will changed to a new tariff ID.</xs:documentation>

                 </xs:annotation>-->

                 <xs:simpleType>

                  <xs:restriction base="xs:string">

                   <xs:maxLength value="10"/>

                  </xs:restriction>

                 </xs:simpleType>

                </xs:element>

                <xs:element name="toTariffRef" minOccurs="1" maxOccurs="1">

                 <!--<xs:annotation>

                  <xs:documentation xml:lang="EN">This is the new tariff ID that the meter will be changed to.</xs:documentation>

                 </xs:annotation>-->

                 <xs:simpleType>

                  <xs:restriction base="xs:string">

                   <xs:maxLength value="10"/>

                  </xs:restriction>

                 </xs:simpleType>

                </xs:element>

                <xs:element name="effectiveDate" type="xs:date" minOccurs="1" maxOccurs="1">

                 <!--<xs:annotation xml:lang="EN">

                  <xs:documentation>This is the effective from date for the commencement of the new tariff</xs:documentation>

                 </xs:annotation>-->

                </xs:element>

               </xs:sequence>

              </xs:complexType>

             </xs:element>

             <xs:element name="RefreshTariff">

              <!--<xs:annotation xml:lang="EN">

               <xs:documentation xml:lang="EN">This is the 'Refresh Tariff' option for the tariff configuration. This will allow the existing tariff ID on a meter to be updated to reflect any changes to the details for that tariff.</xs:documentation>

              </xs:annotation>-->

              <xs:complexType>

               <xs:sequence>

                <xs:element name="tariffRef" minOccurs="1" maxOccurs="1">

                 <!--<xs:annotation>

                  <xs:documentation xml:lang="EN">This is the  tariff ID that is expected to be on the meter and will be updated to reflect any changes to the details for that tariff.</xs:documentation>

                 </xs:annotation>-->

                 <xs:simpleType>

                  <xs:restriction base="xs:string">

                   <xs:maxLength value="10"/>

                  </xs:restriction>

                 </xs:simpleType>

                </xs:element>

                <xs:element name="effectiveDate" type="xs:date" minOccurs="1" maxOccurs="1">

                 <!--<xs:annotation>

                  <xs:documentation xml:lang="EN">This is the effective from date for the commencement of the updated tariff details.</xs:documentation>

                 </xs:annotation>-->

                </xs:element>

               </xs:sequence>

              </xs:complexType>

             </xs:element>

            </xs:choice>

           </xs:complexType>

          </xs:element>

         </xs:sequence>

        </xs:complexType>

       </xs:element>

       <xs:element name="responseStatus" type="ResponseStatusDT" minOccurs="0"/>

       <xs:element name="rejectionReason" minOccurs="0">

        <xs:simpleType>

         <xs:restriction base="xs:string">

          <xs:maxLength value="200"/>

         </xs:restriction>

        </xs:simpleType>

       </xs:element>

      </xs:sequence>

     </xs:complexType>

    </xs:element>

   </xs:sequence>

   <xs:attribute name="ParticipantID" type="xs:string" use="required"/>

  </xs:complexType>

</xs:element>

<xs:simpleType name="ResponseStatusDT">

  <xs:restriction base="xs:string">

   <xs:enumeration value="Success"/>

   <xs:enumeration value="Failed"/>

  </xs:restriction>

</xs:simpleType>

</xs:schema>

javier_alcubilla
Contributor
0 Kudos

How it's configured?

Could you show your ICO?

former_member1330829
Participant
0 Kudos

Hi Javier,

It is a F2F interface using ICO

the Bean is configured on the sender file channel

former_member1330829
Participant
0 Kudos
former_member191435
Contributor
0 Kudos

Hi Tanzoom,

Please check below thread

http://scn.sap.com/thread/74777

Thanks,

Sreenivas

javier_alcubilla
Contributor
0 Kudos

Test 1

1. Remove XMLAnonymizer module

2. Deactivate schema validation at ICO configuration

3. Test again.

Test 2

1. Activate schema validation

If doesn't work, refer to Sreenivas thread: http://scn.sap.com/thread/74777 because your schema includes elementFormDefault="qualified"

Test 3.

Modify the schema manually removing that line (elementFormDefault="qualified") and test again

If it works, the problem is the schema. Maybe you can contact to provider to remove that string