cancel
Showing results for 
Search instead for 
Did you mean: 

xml file starting with number rather than tag.

Former Member
0 Kudos

Hello Experts,

1. Business is sending xmlv2 file starting file size and then tag.

004605                       

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

<Saa:DataPDU xmlns:Saa="urn:swift:saa:xsd:saa.2.0" xmlns:Sw="urn:swift:snl:ns.Sw" xmlns:SwInt="urn:swift:snl:ns.SwInt" xmlns:SwGbl="urn:swift:snl:ns.SwGbl" xmlns:SwSec="urn:swift:snl:ns.SwSec">

     <Saa:Revision>2.0.3</Saa:Revision>

     <Saa:Header>

         <Saa:TransmissionReport>...............

In PI message mapping I am getting

Runtime exception occurred during application mapping com/sap/xi/tf/_xxxx_; com.sap.aii.utilxi.misc.api.BaseRuntimeException:Content is not allowed in prolog.

If I test from RWB removing the file size. Interface is working fine.

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

<Saa:DataPDU xmlns:Saa="urn:swift:saa:xsd:saa.2.0" xmlns:Sw="urn:swift:snl:ns.Sw" xmlns:SwInt="urn:swift:snl:ns.SwInt" xmlns:SwGbl="urn:swift:snl:ns.SwGbl" xmlns:SwSec="urn:swift:snl:ns.SwSec">

Can some one tell me how to handle these kind of messages in PI.Do we have any option to remove this number and pass the message to mapping.

2. I am using XMLAnonymizer to convert Saa to ns0. I have provided the parameter values as below in the module tab.

anonymizer.acceptNamespaces     urn:swift:saa:xsd:saa.2.0" xmlns:Sw="urn:swift:snl:ns.Sw" xmlns:SwInt="urn:swift:snl:ns.SwInt" xmlns:SwGbl="urn:swift:snl:ns.SwGbl" xmlns:SwSec="urn:swift:snl:ns.SwSec"

anonymizer.quote     ns0

Still I could see Saa in the payload. what value I should provide to chang the payload "Saa"with ns0.

Thanks,

Lavanya

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos

Hi LAvanya,

Have you thought to use the sender file adapter instead of the sender SOAP?, or you sender third-system send the message as attachment?

Regards.

Former Member
0 Kudos

Hello Vila,

This is file to proxy scenario.I am using sender file adapter to pick the file.

No, its not an attachment. Third party place the file in a folder. we will pick the file as it is and map to proxy service. While doing mapping getting this issue.


Regards

Lavanya

former_member181985
Active Contributor
0 Kudos

Hi Lavanya,

Does file size in the xml file at first place has any significance in terms of business requirement. If not, you can ask source system to generate only xml file with no file size value at the beginning of xml file.

Else if file size has some significance, then use java mapping to remove the file size value from xml file. You can make use of simple java api e.g., substring() to get the required xml content for next graphical mapping

Best Regards,

Praveen Gujjeti

Former Member
0 Kudos

Hello Praveen,

Thank you for the response.

I have checked with Business and got confirmation that, they cannot send the message without file size value in the xml file. So now I have to go with java mapping.

Can you help me to create the java mapping code to get the output without value.

Thanks & Regards,

Lavanya.

former_member181985
Active Contributor
0 Kudos

Hi Lavanya,

Try with below java code,


import java.io.*;

import com.sap.aii.mapping.api.*;

public class GetOnlyXMLJM extends AbstractTransformation {

        public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException

  {

  try

  {

  int len = 0;

  byte[] buffer = new byte[1024];

  ByteArrayOutputStream baos = new ByteArrayOutputStream();

  InputStream is = (InputStream) in.getInputPayload().getInputStream();

  while ((len = is.read(buffer)) > 0)

  {

  baos.write(buffer, 0, len);

  }

  String str = baos.toString();

  str = str.substring(str.indexOf("<"));

  out.getOutputPayload().getOutputStream().write(str.getBytes());

  }

  catch(Exception e)

  {

  throw new StreamTransformation(e.getMessage());

  }

        }

}

//BR,

Praveen Gujjeti

Former Member
0 Kudos

Hello Praveen,

Thank you very much. Your code is working perfectly for my requirement. Flow is working fine now.

Regards,

Lavanya

former_member181985
Active Contributor
0 Kudos

Hi Lavanya,

Glad to know. Please mark this thread as answered, it will be useful for other members

//BR,

Praveen Gujjeti

Answers (0)