cancel
Showing results for 
Search instead for 
Did you mean: 

Namespace prefix error in Message mapping

former_member601528
Participant
0 Kudos

Dear All,

I'm doing File to Idoc scenario, i'm getting an error as " Error in IDOC Adapter Processing "

:" XML IDoc conversion: No known segments identified" in SXMB_MONI.

When i tested the payload from moni, my data segment is not populating. I'm getting recordset and EDI_DC40 segments, but under the EDI_DC40 one more segment is also there i.e ZCRDBK1 containing data fields, this segment is not displaying in the MONI and found that that the problem is with the namespace prefix.

In general, the namespace prefix will be, ns0. But in my case, it's showing it as a ns instead of ns0". How to change the namespace prefix from ns to ns0 in the structure of file.

My actual message mapping payload is : This is without any data:

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

<ns0:CardMachineBreakupCreate xmlns:ns0="urn:modi.com:POS:CardMachineBreakUp">

   <Recordset>

      <CardDetails>

         <SiteCode/>

         <PostingDate/>

         <MIDC_Code/>

         <ProfitCentre/>

         <MachineAmt/>

      </CardDetails>

   </Recordset>

</ns0:CardMachineBreakupCreate>


and i gave the manual entries in the message mapping the source payload structure is :

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

<ns0:CardMachineBreakupCreate xmlns:ns0="urn:modi.com:POS:CardMachineBreakUp">

   <Recordset>

      <CardDetails>

         <SiteCode>c001</SiteCode>

         <PostingDate>20130225</PostingDate>

         <MIDC_Code>ICICI</MIDC_Code>

         <ProfitCentre>C001GEN</ProfitCentre>

         <MachineAmt>1500</MachineAmt>

      </CardDetails>

   </Recordset>

</ns0:CardMachineBreakupCreate>

The actual payload structure from SXMB_MONI is like this:

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

<ns:CardMachineBreakupCreate xmlns:ns="urn:modi.com:POS:CardMachineBreadkUp">

<Recordset>

    <CardDetails>

        <SiteCode>C001</SiteCode>

        <PostingDate>20130311</PostingDate>

        <MIDC_Code>ICICI123</MIDC_Code>

        <ProfitCentre>C001GEN</ProfitCentre>

        <MachineAmt>150000</MachineAmt>

    </CardDetails>

</Recordset>

</ns:CardMachineBreakupCreate>

Is the problem is with the namespace prefix or any other issue is there.please let me know ? Because i have mapped all the mandatory fields in idoc control record of message mapping. Even i tried with reimporting the metadata also, but no result.

Regards,

Aravind


Accepted Solutions (0)

Answers (7)

Answers (7)

former_member601528
Participant
0 Kudos

issue resolved, thanx for all your inputs..

Former Member
0 Kudos

Aravind,

You can use below Java mapping to replace ns with ns0. This Java mapping should be placed before message mapping.

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.io.OutputStream;

import java.util.Map;

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

public class AddPrefixToNamespace {
private Map paramters;
StringBuffer out_value = new StringBuffer();

public void setParameter(Map map) {
  paramters = map;
}

public void execute(InputStream in, OutputStream out)
   throws StreamTransformationException {

  BufferedReader br = new BufferedReader(new InputStreamReader(in));
  String line;
  int find;
  try {
 
   while ((line = br.readLine()) != null) {
             if((find = line.IndexOf("<ns:CardMachineBreakupCreate           

                xmlns:ns=\"urn:modi.com:POS:CardMachineBreadkUp\">")) != -1)

   {


     line = line.replaceAll("<ns:CardMachineBreakupCreate          

                xmlns:ns=\"urn:modi.com:POS:CardMachineBreadkUp\">",

               "<ns0:CardMachineBreakupCreate xmlns:ns0=\"urn:modi.com:POS:CardMachineBreadkUp\">"

    }
   if ((find = line.indexOf("</CardMachineBreakupCreate>")) != -1) {
     line = line.replaceAll("</CardMachineBreakupCreate>","</ns0:CardMachineBreakupCreate>");
    }
    out_value.append(line);
   }
   out.write(new String(out_value).getBytes());
  }catch (IOException e) {
   e.printStackTrace();
  }
}

}

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Aravind,

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

<ns0:CardMachineBreakupCreate xmlns:ns0="urn:modi.com:POS:CardMachineBreakUp">

   <Recordset>

      <CardDetails>

         <SiteCode>c001</SiteCode>

         <PostingDate>20130225</PostingDate>

         <MIDC_Code>ICICI</MIDC_Code>

         <ProfitCentre>C001GEN</ProfitCentre>

         <MachineAmt>1500</MachineAmt>

      </CardDetails>

   </Recordset>

</ns0:CardMachineBreakupCreate>

and

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

<ns:CardMachineBreakupCreate xmlns:ns="urn:modi.com:POS:CardMachineBreadkUp">

<Recordset>

    <CardDetails>

        <SiteCode>C001</SiteCode>

        <PostingDate>20130311</PostingDate>

        <MIDC_Code>ICICI123</MIDC_Code>

        <ProfitCentre>C001GEN</ProfitCentre>

        <MachineAmt>150000</MachineAmt>

    </CardDetails>

</Recordset>

</ns:CardMachineBreakupCreate>

are semantically the same. There is no problem with the payload as long as the namespace prefixes are properly declared e.g xmlns:ns="urn:modi.com:POS:CardMachineBreadkUp" should be equal to

xmlns:ns0="urn:modi.com:POS:CardMachineBreadkUp" or xmlns:ns1="urn:modi.com:POS:CardMachineBreadkUp" and so on. Try executing in message mapping with the ns payload, it should get processed

Hope this helps,

Mark

rajasekhar_reddy14
Active Contributor
0 Kudos

It looks sender system sending data with prefix ns, try to fix in sender system otherwise use to change prefix to nso.

1)XSLT Mapping

2)JAVA Mapping

former_member184789
Active Contributor
0 Kudos

Hi Aravind.

As Baskar specified, the solution is to have XML Anonymizer bean to replace namespace prefix. You can also go for XSLT mapping for replacing prefix. You can refer to:

http://social.msdn.microsoft.com/Forums/en-US/biztalkgeneral/thread/ad6dd94f-100d-40aa-a57b-2cabaf8e...

http://stackoverflow.com/questions/10124887/how-to-replace-namespace-prefix-in-element-and-attribute...

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You can remove the namespace prefix or define namespace prefix for namespace using XMLAnonymizerBean.  Please refer this link

http://help.sap.com/saphelp_nw04/helpdata/en/45/d169186a29570ae10000000a114a6b/content.htm

Former Member
0 Kudos

Hi ,

Take the payload from test tab of your message mapping and process the message from rwb/integration engine/test. -->You will get to know whether is it due to namespace issue or any other.

By the way at what stage message got failed.At mapping level or before/after that?

You can simply track it ,by looking into trace.Hit on trace button in  sxmb_moni and dig for reason for which message got failed.

Regards

Venkat

former_member601528
Participant
0 Kudos

Dear Venkat,

When i test the payload from message mapping in RWB, the message got processed successfully without any issue and also i'm getting the namespace prefix as ns0 But when i'm process the actual file, one of the segment of idoc is not appearing in MONI. here i'm getting the namespace prefix as ns.

What might be the problem.please suggest any solution to this problem.

Thanks,

aravind