How to read XML payload in Adapter module

Hi all,
I have to read content of xml payload inside custom adapter module:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_REQ xmlns:ns0="namespace">
<record>
  <EmployeeName>a</EmployeeName>
  <EmployeeID>9999</EmployeeID>
  </record>
<record>
  <EmployeeName>b</EmployeeName>
  <EmployeeID>9999</EmployeeID>
  </record>
<record>
  <EmployeeName>c</EmployeeName>
  <EmployeeID>9999</EmployeeID>
  </record>
  </ns0:MT__REQ>
obj = inputModuleData.getPrincipalData();
msg = (Message) obj;
XMLPayload xpld = msg.getDocument();
String xmltxt = xpld.getText();
InputStream in = new ByteArrayInputStream(xmltxt.getBytes("UTF-8"));
& then using DOM parser i am trying to read the contents.
But i am not able to read anything. And no exception is raised.
How can i read contents of this xml file.
Thanks,
Mayank

hi,
I am still getting same Blank payload.
My Code for Parsing is:
doc = db.parse((InputStream) xpld.getInputStream());
NodeList list_Set=doc.getElementsByTagName("record");
NodeList list_Set1=doc.getElementsByTagName("EmployeeName");
NodeList list_Set2=doc.getElementsByTagName("EmployeeID");
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "12");
String input = "";
for(int i = 0; i < list_Set.getLength(); i++){
Node f=list_Set1.item(i);
f=f.getFirstChild();
String str_f=f.getNodeValue();
Node f2=list_Set2.item(i);
f2=f2.getFirstChild();
  String str_f2=f2.getNodeValue();
input = input + str_f + "," + str_f2 +  "END" ;
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Value added from incoming payload");
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, input);
And in RWB monitoring, i am able to see:
2009-10-01 14:20:51 Information 12
2009-10-01 14:20:51 Information UNDEFINED
2009-10-01 14:20:51 Information 14
So UNDEFINED is coming for input.
Edited by: Mayank  Gupta on Oct 1, 2009 11:08 AM

Similar Messages

  • How to read .xml file from embedded .swf(flash output) in captivate

    I have been trying to read .xml file from the .swf (Flash output) that is embedded within the captivate file but no luck yet . Please if anyone got any clue on how get this thing done using Action script 3.0 then let me know. I am using Adobe Captivate 5.5 at present and Flash CS 5.5.
    I am well aware about how to read .xml file through action script 3.0 in flash but when insert the same flash in captivate and publish nothing comes in captivate output. I would higly appreciate if anyone could help me out with that.
    Here is is graphical demonstration of my query :
    Message was edited by: captainmkv

    Hi Captainmkv,
    Does the information in this post cover what you're trying to do: http://forums.adobe.com/message/5081928#5081928
    Tristan,

  • How to read xml file and place it into an internal table...

    hello all,
    can any one help me in - how to read xml data file (placed in application server) and placing the same into an internal table (remove the xml tags or say fetching the xml data without xml tags).

    Hi Murashali,
    use this.
    TYPES: BEGIN OF day,
    name TYPE string,
    work(1) TYPE c,
    END OF day.
    DATA: BEGIN OF week,
    day1 TYPE day,
    day2 TYPE day,
    day3 TYPE day,
    day4 TYPE day,
    day5 TYPE day,
    day6 TYPE day,
    day7 TYPE day,
    END OF week.
    DATA xml_string TYPE string.
    DATA result LIKE week.
    week-day1-name = 'Monday'. week-day1-work = 'X'.
    week-day2-name = 'Tuesday'. week-day2-work = 'X'.
    week-day3-name = 'Wednesday'. week-day3-work = 'X'.
    week-day4-name = 'Thursday'. week-day4-work = 'X'.
    week-day5-name = 'Friday'. week-day5-work = 'X'.
    week-day6-name = 'Saturday'. week-day6-work = ' '.
    week-day7-name = 'Sunday'. week-day7-work = ' '.
    CALL TRANSFORMATION ...
    SOURCE root = week
    RESULT XML xml_string.
    CALL TRANSFORMATION ...
    SOURCE XML xml_string
    RESULT root = result.
    Regards,
    Vijay

  • How to read xml file as shown below.

    Hello,
    I am using flash builder 4 and currently working on implementing AIR application.
    I need to read xml file data.
    Normal xml files are easy to read and i am much more aware of it.
    But can any one have idea how to read XML file which is given below.
    <node>
    <key>ID</key>
    <integer>1</integer>
    <key>Name</key>
    <string>Dhwani</string>
    <key>Postno</key>
    <integer>20</integer>
    <key>deskname</key>
    <string>flex</string>
    <key>empid</key>
    <integer>25</integer>
    <key>projectname</key>
    <string>abc</string>
    </node>
    Here i have xml file in form of key value pair. <key> node shows name of the key and after that <integer> or <string> node are the value for that specific key.
    if i select node.key then it shows me all the keys. and from that i cant make out what is the value for key ID.
    Is there any way to take first node and then second. i mean first i ll take value of key and store it into some arraycollection. and then value will be stored.
    Any help is appreciated.. Looking for positive reply.
    Thanks
    Dhwani

    There are different methods to access XML data which have pro's and cons. Let us know more about what you want to do and we can help you.

  • How to read XML file and write into another XML file

    Hi all, I am new to JAVAXML.
    My problem is I have to read one XML file and take some Nodes from that and write these nodes into another XML file...
    I solved, how to read XML file
    But I don't know how to Write nodes into another XML.
    Can anyone help in this???
    Thanks in advance..

    This was answered a bit ago. There was a thread called "XML Mergine" that started on Sept 14th. It has a lot of information about what it takes to copy nodes from one XML Document object into another.
    Dave Patterson

  • How to read XML file and update the data in MS CRM 2011?

    Hi Folks,
    Can anyone please help me finding some references to read XML files and push the data to MS CRM 2011 preferably by using a console application.
    Please let me know if any ways of handling it in simple ways.
    Thanks,
    Sri

    HI,
    How to read XML file:
    https://social.msdn.microsoft.com/Forums/en-US/5dd7261b-86c4-4ca8-ba87-95196ef3ba50/need-to-display-xml-file-in-textboxes-edit-the-data-and-save-the-new-xml-file?forum=csharpgeneral
    How to work with CRM:
    ClientCredentials credentials = new ClientCredentials();
    credentials.Windows.ClientCredential = new System.Net.NetworkCredential("USER", "Password", "Domain");
    Uri uri = new Uri("http://server/Organization/XRMServices/2011/Organization.svc");
    OrganizationServiceProxy proxy = new OrganizationServiceProxy(uri, null, credentials, null);
    proxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
    IOrganizationService service = (IOrganizationService)proxy;
    //using "service" you can create, update and retrieve entities.
    More information here about service functions:
    https://msdn.microsoft.com/en-us/library/gg328198.aspx

  • How to read xml

    I'm getting xml from   customFieldsFeed.getEnumerationValues()  it is comming from  a web services looks like this
    <xml-fragment xmlns:b=""http://schemas.microsoft.com/2003/10/Serialization/Arrays""
    xmlns:i=""http://www.w3.org/2001/XMLSchema-instance""
    xmlns:a=""http://schemas.xxxxxxxx""
    xmlns:u=""http://docs.oasis-open.org/wss/xxxxxxx-utility-1.0.xsd""
    xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/"">
      <b:anyType i:type=""a:Enumeration"">
        <a:EnumerationID>AAAAA</a:EnumerationID>
        <a:Name>A3 MFD</a:Name>
      </b:anyType>
      <b:anyType i:type=""a:Enumeration"">
        <a:EnumerationID>BBBBB</a:EnumerationID>
        <a:Name>A3 Printer</a:Name>
      </b:anyType>
      <b:anyType i:type=""a:Enumeration"">
        <a:EnumerationID>CCCCC</a:EnumerationID>
        <a:Name>A4 MFP</a:Name>
      </b:anyType>
    </xml-fragment>"
    I need to read EnumerationID ex if AAAAA need to retrive Name value " A3 MFD"
    java 1.6
    Thanks,
    HJ

    This could be a starting point:
    http://stackoverflow.com/questions/2811001/how-to-read-xml-using-xpath-in-java
    bye
    TPD

  • How to read XML SpreadSheet using OleDb Provider

    Hi All,
    I have generated an xml spreadsheet (*.xls) using XSL. I have another program that reads this spreasheet and processes it.
    Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + filnavn + ";" + "Extended Properties=Excel 8.0;"
    Dim objCon As OleDbConnection = New OleDbConnection(sConnectionString)
    objCon.Open()
    Dim objCmdSelect As OleDbCommand = New OleDbCommand("SELECT * FROM [General$]", objCon)
    Dim objAdapater As OleDbDataAdapter = New OleDbDataAdapter()
    objAdapater.SelectCommand = objCmdSelect
    Dim _DSGen As DataSet = New DataSet()
    objAdapater.Fill(_DSGen)
    I m facing an issue while opening a connection to the generated spreadsheet. It says "{"External table is not in the expected format."}".
    My Connection string is
    "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + filnavn + ";" + "Extended Properties=Excel 8.0;"
    Do i need to change anything to this string ? I tried using a dataset and calling dataSet.ReadXml(excelFileName); But the dataset doesnt contain my table. Any inputs on how to read an xml spreadsheet ?
    How to read XML SpreadSheet in OleDb? How to Convert XML SpreadSheet to Microsoft Office Excel Sheet?
    Many Thanks

    Hi,
    You'lll most likely have better luck posting this in a Microsoft forum. This forum deals with issues specific to querying the Oracle database via the Oracle OLEDB provider.
    Cheers,
    Greg

  • How to read XML message present in Table using PL/SQL?

    Hi,
    How to read XML content present in Table using PL/SQL .And is it possible to parse the xml uisng xslt and insert xml output in same table again ?
    Thanks!

    Late reply, but hopefully better late than never.
    You can possibly do it all via a single SQL statement, such as {message:id=4232077}
    XMLTable Syntax can be found at http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions228.htm#CIHGGHFB (for 10.2 users) else find your correct version at http://www.oracle.com/technology/documentation/index.html

  • Covnert Complex XML to Simple XML tags using Adapter Module

    Hi
    <buyer>
    <fnParty:partyIdentifier partyIdentifier="GER" partyIdentifierQualifierCode="SenderAssigned"/>
    </buyer>
    I want to convert above complex xml into following simple xml document
    <buyer>GER</buyer>
    I am writing adapter module. Could any one please tell me how to convert this
    Regards
    Sowmya

    Hi,
    Is partyidentifier is source xml and buyer in target xml?
    You can map the attribute to buyer element in message mapping itself.
    Why do you want adapter module?
    Thanks,
    Beena.

  • Reading XML payload from text file

    Hello,
    I have a text file with XML payload in it. The text file has some header information and then the XML payload. How do I read only the XML payload for processing in PI?
    the structure of the text file is something like this..
    Header Information
    Payload
    Sample:
    #Datetime: 20140318-09:28:50.129
    #MessageID: sample123
    #Sender: TEST
    #SenderParty: TEST
    #ReceiverService:
    #ReceiverParty: Test
    #Interface: Test123
    #InterfaceNamespace: http://test.com
    <?xml version="1.0" encoding="UTF-8"?>
    <Sample ><Header>......
    Please advise.
    Thank you.
    Larry.

    package com.learning.utils;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.Reader;
    import com.sap.aii.mapping.api.AbstractTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    public class FetchPayload extends AbstractTransformation {
      String strData = null;
      @Override
      public void transform(TransformationInput arg0, TransformationOutput arg1)
      throws StreamTransformationException {
      // TODO Auto-generated method stub
      getTrace().addInfo("File Reading started ");
      String strData = convertStreamToString(arg0.getInputPayload()
      .getInputStream());
      getTrace().addInfo("File Reading successfully completed ");
      try {
      getTrace().addInfo("Generating XML started");
      strData.substring(strData.indexOf("<?xml"), strData.length());
      arg1.getOutputPayload().getOutputStream().write(
      strData.getBytes("UTF-8"));
      getTrace().addInfo("Generating XML started");
      } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      public String convertStreamToString(InputStream in) {
      StringBuffer sb = new StringBuffer();
      try {
      InputStreamReader isr = new InputStreamReader(in);
      Reader reader = new BufferedReader(isr);
      int ch;
      while ((ch = in.read()) > -1) {
      sb.append((char) ch);
      reader.close();
      } catch (Exception exception) {
      return sb.toString();
    and u can get  the xml as a resultant which  u can use as input for next message mapping.
    thanks and regards,
    Praveen T

  • Problem changing XML element in Adapter Module

    Hey!
    I am developing an adapter module to transform a coded password back to clear text. I have access to the XML element where the password is and I get to transform it, but I have 2 problems as also stated in the code:
    1) I cannot set the new value back to the node. I try with
    firstNode.getFirstChild().setNodeValue(decodedPwd);
    but this does not seem to work. How can I achieve this?
    2) Between the first issue and the code
    msg.setDocument(xmlpayload);
    I am not sure how to get my new values for the node back in the XMLPayload. How can I achieve this?
    Here is the code:
    msg = (Message) inputModuleData.getPrincipalData();
              XMLPayload xmlpayload = msg.getDocument();
              factory = DocumentBuilderFactory.newInstance();
              DocumentBuilder builder = factory.newDocumentBuilder();
              Document document = builder.parse((InputStream)xmlpayload.getInputStream());
              password = (Element)document.getElementsByTagName("ns1:passord").item(0);
              firstNode = password.getFirstChild();                    
              pwd = firstNode.getNodeValue();
              if(pwd != null){
                   decodedPwd = Decoder.decodeString(pwd);
    // THIS FAILS!
              firstNode.getFirstChild().setNodeValue(decodedPwd);
    //HOW TO SET NEW NODE VALUE TO XMLPAYLOAD HERE?
              msg.setDocument(xmlpayload);
              inputModuleData.setPrincipalData(msg);
                   return inputModuleData;          
    Help is much appreciated!
    Thanks!
    regards Ole

    Hey!
    The problem was solved. The code snipped I found was:
                   DOMSource DOMSource = new DOMSource(document);
                   ByteArrayOutputStream myBytes = new ByteArrayOutputStream();
                   Result dest = new StreamResult(myBytes);
                   TransformerFactory tf = TransformerFactory.newInstance();
                   Transformer serializer = tf.newTransformer();
                   serializer.transform(DOMSource, dest);
                   byte[] docContent = myBytes.toByteArray();
                   xmlpayload.setContent(docContent);
                   msg.getDocument().setContent(xmlpayload.getContent());               
    Ole
    Edited by: Ole Mugaas on Mar 27, 2008 8:43 PM

  • How to access FTP server through Adapter Module

    I gone through SDN Search and found no solution with PI Standard Import to support FTP inside the Adapter Module
    Requirement
    This is File to IDoc Scenario.
    I am trying to write Module which takes care of processing 50MB to 100MB file and split based on conditions of the record structure of the file. Where we are trying to reduce the file size and takes care of certain logic by eliminating/building xml etc...while splitting file.
    In order to use FTP library, is there any standard library available or supported by SUN.
    Please advice

    Hi,
    >>>found no solution with PI Standard Import to support FTP inside the Adapter Module
    why would you? file adapter supports FTP - so you don't need it
    >>>In order to use FTP library, is there any standard library available or supported by SUN.
    you can use any java ftp client available on google
    Regards,
    Michal Krawczyk

  • Need help with reading XML using File Adapter

    I have created a simple BPEL process that uses a file adapter to read files containing XML messages of a simple xsd schema. But when reading the xml, I get the following error message:
    [2010/03/01 23:43:13] Invalid data: The value for variable "Receive_1_Read_InputVariable", part "revision-report" does not match the schema definition for this part.The invalid xml document is shown below: More...
    [2010/03/01 23:43:13] "{http://schemas.oracle.com/bpel/extension}invalidVariables" has been thrown. less
    -<invalidVariables xmlns="http://schemas.oracle.com/bpel/extension">
    -<part name="code">
    <code>
    9710
    </code>
    </part>
    -<part name="summary">
    <summary>
    Invalid xml document.
    According to the xml schemas, the xml document is invalid. The reason is: Error::cvc-complex-type.4: Attribute 'doc' must appear on element 'revision-report'.
    Error::cvc-complex-type.4: Attribute 'model' must appear on element 'revision-report'.
    Error::cvc-complex-type.4: Attribute 'pubdate' must appear on element 'revision-report'.
    Error::cvc-complex-type.2.4.b: The content of element 'revision-report' is not complete. One of '{"http://xmlns.oracle.com/xmlfile":alternategroup}' is expected.
    Please make sure that the xml document is valid against your schemas.
    </summary>
    </part>
    </invalidVariables>
    It seems that there is some issue with the namespace, but even after trying out various combinations, I am not able to resolve this.
    Here the message schema (xsd):
    <?xml version="1.0" encoding="UTF-8" ?>
    <xs:schema elementFormDefault="qualified"
    targetNamespace="http://xmlns.oracle.com/xmlfile"
    xmlns:tns="http://xmlns.oracle.com/xmlfile"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="revision-report">
    <xs:complexType>
    <xs:sequence maxOccurs="unbounded">
    <xs:element name="alternategroup">
    <xs:complexType>
    <xs:attribute name="name" use="required" type="xs:string"/>
    <xs:attribute name="Desc" use="required" type="xs:string"/>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    <xs:attribute name="doc" use="required" type="xs:string"/>
    <xs:attribute name="model" use="required" type="xs:string"/>
    <xs:attribute name="pubdate" use="required" type="xs:string"/>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    And here is the xml file to be read by the file adapter:
    <?xml version="1.0" encoding="UTF-8" ?>
    <revision-report doc="doc2" model="model4" pubdate="pubdate5">
    <alternategroup Name="ABC" Desc="ABC-Desc">
    </alternategroup>
    <alternategroup Name="DEF" Desc="DEF-Desc">
    </alternategroup>
    <alternategroup Name="GHI" Desc="GHI-Desc">
    </alternategroup>
    </revision-report>
    Appreciate any help.
    Thanks in advance for your attention.
    Jay

    Thanks for your response.
    I am not sure if there is any easier way, but I tried out the following tool available on the net to check an xml against a xsd:
    http://tools.decisionsoft.com/schemaValidate/
    There were a few issues, that I corrected and finally had a xsd and xml that were matching and valid. I tried this out in my file reading BPEL process, but the error still remained the same!
    Here is my updated/simplified xsd and xml:
    <?xml version="1.0" encoding="UTF-8" ?>
    <xs:schema targetNamespace="http://xmlns.oracle.com/xmlfile"
    xmlns:tns="http://xmlns.oracle.com/xmlfile"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://xmlns.oracle.com/xmlfile">
    <xs:element name="revision-report">
    <xs:complexType>
    <xs:sequence>
    <xs:element maxOccurs="unbounded" ref="alternategroup"/>
    </xs:sequence>
    <xs:attribute name="doc" use="required" type="xs:string"/>
    <xs:attribute name="model" use="required" type="xs:string"/>
    <xs:attribute name="pubdate" use="required" type="xs:string"/>
    </xs:complexType>
    </xs:element>
    <xs:element name="alternategroup">
    <xs:complexType>
    <xs:attribute name="Name" use="required" type="xs:string"/>
    <xs:attribute name="Desc" use="required" type="xs:string"/>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    <?xml version="1.0" encoding="UTF-8" ?>
    <revision-report doc="doc2" model="model4" pubdate="pubdate5" xmlns="http://xmlns.oracle.com/xmlfile">
    <alternategroup Name="ABC" Desc="ABC-Desc"/>
    <alternategroup Name="DEF" Desc="DEF-Desc"/>
    <alternategroup Name="GHI" Desc="GHI-Desc"/>
    </revision-report>
    I even tried the option that is available in JDeveloper to generate a sample xml from a xsd (when in the context of a Transformation activity). The xml generated by this also seems exactly like the one above.
    So, I am not able to figure out why my BPEL process errors out with the message Invalid xml document.

  • How to get file name in adapter module

    Hi all
    Is it possible to get the file name in a adapte module? If so how can I achieve this?

    Hi,
    Check below thread. it shows code for file name.
    [Re: Query regarding Adapter Module development]
    -Gouri

Maybe you are looking for

  • Ipod nano 1st gen (not recognized by iTunes and won't resotre)

    My ipod nano 1st gen has been working fine up untilthis afternoon..I plugged it in as normal while running iTunes and I wanted to remove some music files t add new ones and all of a sudden it wasn't recognized by itUnes anymore, you can't resotre it

  • I have problem with Adobe Photoshop 7.

    I am attempting to open a file I have been working on for a week but it will not open the file and instead gives me a error message, "could not open file because an unexpected end of file was encountered".   I need to access this file as I am unable

  • Video input device

    Question for you all. I want to input video, which is better; 1) Miglia's Directors Cut Take 2 or 2) Canopus ADVC110 analog/Dig. conv. I thank you for your opinion. Russ Andris

  • How can I return my iPhotos icon back onto my HD directory?

    I was trying to access iPhotos and I noticed I can't get to my iPhotos to download a picture.  I double-click on my Mac HD, directory pops up and my iPhotos is no longer on my Favorites list?  How do I put it back?

  • How to close a view

    hello all, I have a view that opens an html view on a button click. how can I go back to the first iview from the html view? I tried to use a toolbar button with different system action - but without success.... thanks, Michal