Testing Adapter Module in NWDS

hi,
I have got a code for adapter module,I wanted to test it standalone using NWDS.
class XML2EdifactBean
public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)
          throws ModuleException { //Some Code... }
I am getting some error while executing the adapter module ,so I want to call the function using main method.Can you provide me with a sample code for this.
regards,
Ujjwal Kumar.

This would be too complex to do all necessary steps for a stand alone test.
I recommend to split the generic adapter module stuff and the part, you really want to do something.
For the adapter modul, which we used on Teched session:
GetHostName.java code for 3.0/7.0
I did following: I introduced a helper class and passed the DOM code
public class HelperClass {
     String hostElementName = "host";
     String hostName = "host";
    public static void main(String[] args) {
        try {
            InputStream in = new FileInputStream(new File("in.xml"));
            OutputStream out = new FileOutputStream(new File("out.xml"));
            new HelperClass().execute(in, out);
        } catch (Exception e) {
            e.printStackTrace();
    public void setHostElementName(String hostElementName){
         this.hostElementName = hostElementName;
    public void setHostName(String hostName){
         this.hostName = hostName;
    public void execute(InputStream in, OutputStream out){
         try  {
              DocumentBuilderFactory factory;
        factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document document = builder.parse(in);
        Element rootNode = document.getDocumentElement();
        if(rootNode != null)  {
            Element childElement =
            document.createElement(hostElementName);
            childElement.appendChild(document.createTextNode(hostName));
            rootNode.appendChild(childElement);
        // Transforming the DOM object to Stream object.
        TransformerFactory tfactory = TransformerFactory.newInstance();
        Transformer transformer = tfactory.newTransformer();
        Source src = new DOMSource(document);
        Result dest = new StreamResult(out);
        transformer.transform(src,dest);
         } catch(Exception e){}
in the bean class, I used the helper class:
     XMLPayload xmlpayload = msg.getDocument();
            InputStream in = xmlpayload.getInputStream();
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            HelperClass hc = new HelperClass();
            hc.setHostElementName(hostElementName);
            hc.setHostName(hostName);
            hc.execute(in,out);
            byte[] docContent = out.toByteArray();
            if(docContent != null)  {
                xmlpayload.setContent(docContent);
                inputModuleData.setPrincipalData(msg);
Now I can test the parser in the NWDI
Regards
Stefan

Similar Messages

  • How to Test Adapter Module in NWDS

    Hi Friends,
    I have written an adapter module. Before deploying on adapter engine, I want to do test in NWDS. Any idea how to do this. Please provide sample java code, if possible.
    Thanks,
    Sandeep Maurya

    Hi,
    Since runtime and module processor framework is not available on your local machine that's why adapter module test not possible using NWDS on local machine.
    Another possibility is to install PCK on some local machine for testing purpose.
    You must deploy (either on PCK or AE) it and test.
    Regards,
    Gourav

  • How to test Adapter Module

    Hi
    My Scenario is File - to - File
    I have written one adapter module and i have deployed in J2ee Engine as well. In sender communication channel i have given the JNDI name like
    <b>"localejbs/<JNDI Name>"</b>.I have tested the my file to file scenario by placing a file in source directory which i have mentioned in Communication channel Source Directory and File Name.But i didnt find any difference in target file.
    I have used the following blog
    <b>
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/da5675d1-0301-0010-9584-f6cb18c04805</b>
    1.How to test the adapter module.
    2.How to configure my communication channel.
    Please help me its very urgent
    Best Regards
    Ravi Shankar B

    Hi,
    check JNDI service in visual admin to see if
    your service has the same name there
    >>>>1.How to test the adapter module.
    by using it in a channel
    >>>>2.How to configure my communication channel.
    add you adapter module to the adapter module tab
    in communication channel
    Regards,
    michal

  • Developing adapter modules for PI 7.0 using NWDS 7.3

    Hello all,
        Did someone have already developed adapter modules for PI 7.0 using NWDS 7.3? I can´t find the EJB libraries for Java 1.4.
        I'm able to develop mapping programs, but I'm not sure if it is possible to create EJB projects.
    Thanks,
    Marcos

    Hi Marcos,
    I haven't tried developing adapter modules in NWDS 7.3 for PI 7.0 myself, but according to the documentation from SAP it is possible to develop J2EE 1.4 compliant applications i.e. EJB 2.1 components, which is used by SAP PI 7.0.
    [http://help.sap.com/saphelp_nw73/helpdata/en/48/fc1e73a0ad2637e10000000a42189d/frameset.htm]
    Because of this backwards-compatibility I would expect that the EJB libraries for J2EE 1.4 should be available directly in NWDS 7.3 somewhere.
    Best regards,
    Jacob

  • What authorization required to deploy module from NWDS 7.1

    Hi Experts,
    Need to deploy custom adapter module from NWDS 7.1 to PI server, Please help me to know exact access/authorization role required one developer to publish the module.
    I have gone through many blogs and thread but not able to find exact administrator role which help to deploy the custom module on PI server.
    Error I am getting in NWDS 7.1, while deploying module:
    Could not establish connection to AS Java on [<server detail>]. Authentication did not succeed. Wrong or missing security credentials (password) for principal [PIUSER], or the specified principal has no permissions to perform JNDI related operations.
    Regards
    Raghav
    Edited by: RaghavTiwari on Feb 4, 2012 8:25 AM

    Hi Raghav,
    Check this [SAP Help link|http://help.sap.com/saphelp_nw73ehp1/helpdata/en/43/1e1bbc5d9206fde10000000a422035/frameset.htm] for User Roles for Adapter and Module Development.
    Regards,
    Raghu_Vamsee.

  • Problem with mail adapter module in PI 7.11

    Hi,
    I modified our adapter module from PI 7.0 to be compatible with PI 7.11 SPS3. I followed the instruction in http://www.sdn.sap.com/irj/scn/index;jsessionid=(J2EE3417300)ID1491632150DB11633962752589437606End?rid=/library/uuid/c0b39e65-981e-2b10-1c9c-fc3f8e6747fa&overridelayout=true and successfully deployed the adapter module using NWDS for PI 7.1. However, I am encountering this error in the communication channel monitoring:
    Exception caught during processing mail message com.sap.aii.af.lib.mp.module.ModuleException.
    I don't see any other details in the communication channel monitoring to help me determine the cause of the problem after this error message line. In NWDS, there was no error when I excute build the project. During deployment in NWDS, it says deployment was successful. When I check in NWA, I can find that the adapter module has been deployed successfully. I even tried to re-create the whole adapter module from scrach following the documentation for the 2nd time and still I got the same error message.
    I am using java SDK 6.
    Any help or suggestion would be greatly appreciated.
    Regards,
    Elbert

    Hi,
    This problem is now solved. I am using the correct version of NWDS for PI7.1 and using java 1.6 will not cause any problem.
    The problem was caused by the source data being zipped instead of the unzipped version that my module is expecting. Furthermore, since my module comes before the mail bean, there is no details in the communication channel monitoring that the data sent was a wrong format.
    Regards,
    Elbert

  • Standard adapter modules in sap xi

    Hi,
    Can any one provide me the standard adpter modules in XI and the procedure to use them in the communication channel.
    Thanks,
    Rajeev.

    Hi,
    Go with these blogs.
    SAP NetWeaver Process Integration 7.1: Available Adapters and Adapter Modules
    TechEd 2006: EPI350 - Developing and Testing Adapter Modules in SAP NetWeaver Exchange Infrastructure
    these will help u out

  • Crating adapter modules in XI

    Hi
    I went through a blog on this and seen that we need some jar files inorder to develop this. these are files they have mentioned in the blog
    aii_af_lib.sda,
    aii_af_svc.sda and
    aii_af_cpa_svc.sda.
    Where are these files placed in the XI server. can naybody please tell me the exact location.
    thanks

    Hi Sudhakar,
    These files to be deployed in Netweaver developer studio .
    Plz do refer the following blog it explains clearly...
    Adapter Module Development & Module Configuration
    Also refer...
    ADAPTER MODULES
    how to create modules on j2ee engine
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/02706f11-0d01-0010-e5ae-ac25e74c4c81
    Alerts from adapter modules - the JRA way!!
    Alerts from adapter modules - the JRA way!!
    Alerts from adapter modules - the JRA way!!
    Alerts from adapter modules - the JRA way!!
    RFC calls from Adapter modules...the Web Service Way!
    RFC calls from Adapter modules...the Web Service Way!
    TechEd 2007: EPI351 - Developing User Enhancement Modules in the Adapter Engine
    TechEd 2007:  EPI351 - Developing User Enhancement Modules in the Adapter Engine
    TechEd 2006: EPI350 - Developing and Testing Adapter Modules in SAP NetWeaver Exchange Infrastructure
    TechEd 2006: EPI350 - Developing and Testing Adapter Modules in SAP NetWeaver Exchange Infrastructure
    Migrate from Java embedding in Oracle BPEL to Adapter modules in SAP XI
    Migrate from Java embedding in Oracle BPEL to Adapter modules in SAP XI
    XI Mapping Module for AFW
    The specified item was not found.
    XI: Dynamic configuration in adapter modules - one step further
    The specified item was not found.
    Adapter Module Development & Module Configuration
    Adapter Module Development & Module Configuration
    Dynamic configuration in adapter modules
    Dynamic configuration in adapter modules
    Rename Attachment Adapter Module
    Rename Attachment Adapter Module
    Regards,
    Vinod.

  • Need Help in Creating adapter module for SFTP Sender in NWDS

    Hi experts,
    I have a scenario where i should write an adapter module for SFTP sender in NWDS.. need your help in achieving this..

    Hello,
    >>i have followed the procedure of FTP but, adapter is not picking the file
    Make sure u have written proper expression to pick file.
    >>do we have any different adapter parameters for SFTP... the input file is .csv..
    I don't think there are any specific parameters needed for SFTP (but in case u are reading file name in AM then u might have to adjust SFTP namespace)
    Thanks
    Amit Srivastava

  • Deploy Adapter-Module PI 7.1 with NWDS 7.1 to server?

    Hey,
    i am developed a adapter-module for PI 7.0 now i am upgrading the module to PI 7.1.
    I got the NWDS, all libs and build all Projects like it was described in a SAP Help skript.
    I created a new Project,
    added the EJB module,
    adjusted the decriptor file application-j2ee-engine.xml
    BUT where is the tag  to deploy the Module to the Server?
    In NWDS 7.0 where a tag like "deploy to J2EE engine" where is it in the NWDS 7.1.??
    Please help how to deploy my module to the server an where i can make the settings like the host and the port for the server?
    Thank you all

    Hi,
      Check these if you haven't checked already:
    Check the section 4.11 of this article
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c0b39e65-981e-2b10-1c9c-fc3f8e6747fa?overridelayout=true
    Re: Deploy Custom Adapter Module in PI 7.1
    Customer Module Deployment in PI 7.1
    Regards,
    Ravi
    Edited by: Ravi Kanth Talagana on Jul 23, 2009 4:12 PM

  • NWDS 7.1 for adapter module of PI 7.1

    hi experts,
    i have been trying to develop an adapter module for PI 7.1 using this how to guide
    https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/c0b39e65-981e-2b10-1c9c-fc3f8e6747fa&overridelayout=true
    I have downloaded the NWDS, but in the EJB project wizard..on page 11 in the guide above
    Target Runtime : SAP librarues
    Configuration : SAP EJB J2EE 1.4 project
    I m not getting the above, it just sez default J2EE runtim elibraries...
    also after completion of wizard im unable to get enterprise bean in the file context menu
    am i missing soomething..?pls help me out

    Hi Guys,
    I was goin thru this pdf to convert adapter module for 7.0 t 7.1
    I have added all the jars..how evre in the wizard as mentioned on page 8 of http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/d0667f56-96c7-2b10-0e9a-c40fbd523f4d&overridelayout=true
    Add server libraries.. choose server runtime  choose SAP libraries..
    what r thee SAP libraries..do i have import soem mor ejars?
    can anyone pls let me know

  • Adapter Module to convert text message to XML

    Hello Experts,
    I am writing a custom adapter module to convert the text  content to XML message at the sender adapter end.
    I have followed the steps mentioned in the "HowToCreateModulesforJ2EEAdapterEngine" guide available on SDN.
    I have created the java logic in the process mesthod of the bean to conver the text message to XML paylod (don't know if it is correct). I do not have much idea about the Adpater API methods.
    Can anybody help me with the logic to convert the text msg to xml paylod using adapter frame work APIs or is there any way I can debug and test my logic in NWDS.
    Any help will be greatly appreciated.
    - Rajan

    Hi ,
    To convert Text message to XML why yiu want to go for Adapter Module?? Using file content conversion it self you can do it right?????
    There is no standard logic to convert text file to XML, the logic purely depends on your text message format.
    Regards,
    Raj

  • Adapter Module error

    Hi,
    I made some code changes to a file adapter module code which was working fine [ before the changes were made].
    After making the changes and redeploying the adapter module 'am getting the following error in the RWB communication channel monitoring.
    Error: com.sap.engine.services.ejb.exceptions.BaseTransactionRolledbackLocalException: Exception thrown in method process. The transaction is marked for rollback.
    Any possible reasons for this error?
    Thanks,
    Anand

    Hi,
    Tested the code 'standalone' in the NWDS.No issues with the code execution.
    This particular project was imported from a colleagues machine into my NWDS...not sure if any settings have gone kaput because of that?
    Proabably I would try recreating the EJB project with the exact same steps in my NWDS and then check.
    Thanks,
    Anand

  • Adapter Module Filename in File Receiver Channel

    Hi All,
    is it possible to set the Filename in File Receiver Adapter from Adapter Module?
    I know that it is possible to read the data      
    Channel ch = new Channel(moduleContext.getChannelID());
    path = ch.getValueAsString("file.targetDir");
    I Need to set the filename in Adapter Module, using of Payload is not possible because Payload is not xml.
    Dynamic Parameters in Message Header is not possible because it is an multi mapping process an i need dynamic Filename for each Part
    payload after mapping is like
    MainDocument
    SubMainDocument
    MainDocument
    SubMainDocument
    i need special Name for each SubMainDocument in FileReceiverAdapter
    regards
    ralf

    Hello Stefan,
    interface mapping is an mapping  like this:
    outbound_interface => Inbound_Interface1
                                 => Inbound_Interface2
                                => Inbound_Interface3
    in sxmb_moni this looks like this
    Soap_Header
    Soap_Body
    Payloads
         =>MainDocument ( application/xml )
        => SubMainDocument ( text/xml )
         =>MainDocument ( application/xml )
        => SubMainDocument ( text/xml )
    First SubMainElement is routing to FileReceiverAdapeter A   where Filename has to be like "NameA%nr%"
    second SubMainElement is routing to FileReceiverAdapeter B   where Filename has to be like "NameB%nr%" 
    %nr% is som value from the Payload.
    Payload is not xml  because using of Conversion Argent!!
    I Think there is only one Dynamic in Header for all subelements, i have test it!
    ralf

  • ModuleData.getPrincipalData returns null in the adapter module development

    Hi gurus,
    i am doing a test on the adapter module development following an article written by William Li:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0ac06cf-6ee2-2c10-df98-e17430ca5949?QuickLink=index&overridelayout=true
    my problem is after the EJB has been deployed, it seems that the return of inputModuleData.getPrincipalData() is always null which makes the program can not get the xml payload from the framework.
    the main process of the example has been simplified like this:
         public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData) throws ModuleException {
              Object           obj = null;
              try {
              obj = inputModuleData.getPrincipalData();
              Message     msg1 = (Message) obj;          
                    XMLPayload xmlpayload = msg1.getDocument();}          
              catch (Exception e) {
                   ModuleException me = new ModuleException(e);
                   throw me;
              return inputModuleData;
    after deployed, i get the following error in the adapter monitor of RWB: (my JNDI is testtest)
    17.02.2012 17:13:44.643 Information Send binary file  "test8.xml" from FTP server "10.18.48.150:/encrypt_test/", size 206 bytes with QoS EO
    17.02.2012 17:13:44.644 Information MP: processing local module localejbs/CallSapAdapter
    17.02.2012 17:13:44.644 Information Application attempting to send an XI message asynchronously using connection File_http://sap.com/xi/XI/System
    17.02.2012 17:13:44.645 Information Trying to put the message into the send queue
    17.02.2012 17:13:44.648 Information MP: processing local module localejbs/testtest
    17.02.2012 17:13:44.648 Error MP: exception caught with cause java.lang.NullPointerException: while trying to invoke the method com.sap.engine.interfaces.messaging.api.Message.getDocument() of an object loaded from local variable 'msg1'
    whereas if the code has been changed like this:
         public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData) throws ModuleException {
              Object           obj = null;
              try {
                   obj = inputModuleData.getPrincipalData();
                   Message     msg1 = (Message) obj;     
                   if (obj != null )
                        XMLPayload xmlpayload = msg1.getDocument();
              catch (Exception e) {
                   ModuleException me = new ModuleException(e);
                   throw me;
              return inputModuleData;
    the file can be read by the file adapter.
    i just quite confused that why the return of the getPrincipalData() is null? where is the problem? thanks
    Edited by: Stephen Xue on Feb 17, 2012 5:22 AM

    I'm gonna reply to myself here. I changed the processing sequence of the adapter modules in the  in the FileSender channel so that my module comes first then CallSapAdapter. Then getPrincipalData() contains the message.
    Hope this helps someone else.

Maybe you are looking for