Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

If you are having a requirement of setting SOAP action in single channel, we could go with custom adapter module. The code which I am using is as below:

package com.pi.module;

import javax.ejb.Stateless;

import java.rmi.RemoteException;

import java.util.Timer;

import javax.ejb.EJBException;

import javax.ejb.SessionBean;

import javax.ejb.SessionContext;

import javax.xml.parsers.*;

import org.w3c.dom.*;

import com.sap.aii.af.lib.mp.module.Module;

import com.sap.aii.af.lib.mp.module.ModuleContext;

import com.sap.aii.af.lib.mp.module.ModuleData;

import com.sap.aii.af.lib.mp.module.ModuleException;

import com.sap.aii.af.service.auditlog.Audit;

import com.sap.engine.interfaces.messaging.api.Message;

import com.sap.engine.interfaces.messaging.api.MessageKey;

import com.sap.engine.interfaces.messaging.api.MessagePropertyKey;

import com.sap.engine.interfaces.messaging.api.XMLPayload;

import com.sap.engine.interfaces.messaging.api.auditlog.AuditLogStatus;

/**

* Session Bean implementation class DynamicSOAPAction

*/

@Stateless

public class DynamicSOAPAction implements DynamicSOAPActionRemote, DynamicSOAPActionLocal,SessionBean, Module {

    /**

     * Default constructor.

     */

    public DynamicSOAPAction() {

// TODO Auto-generated constructor stub

    }

    public ModuleData process(ModuleContext moduleContext,ModuleData inputModuleData)throws ModuleException {

Object obj = null;

Message msg = null;

MessageKey amk = null;

String soapAction = null;

      

          String createSOAPAction = (String) moduleContext.getContextData("CreateAction");

String deleteSOAPAction = (String) moduleContext.getContextData("DeleteAction");

String modifySOAPAction = (String) moduleContext.getContextData("ModifyAction");

String rootNode1 = (String) moduleContext.getContextData("CreateNode");

String rootNode2 = (String) moduleContext.getContextData("DeleteNode");

String rootNode3 = (String) moduleContext.getContextData("ModifyNode");

          try{

// Retrieves the current principle data, usually the message , Return type is Object

obj = inputModuleData.getPrincipalData();

// A Message is what an application sends or receives when interacting with the Messaging System.

msg = (Message) obj;

// MessageKey consists of a message Id string and the MessageDirection

amk = new MessageKey(msg.getMessageId(),msg.getMessageDirection());

// Audit log message will appear in MDT of Channel Monitoring

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"Dynamic SOAPAction Module called");

// Returns the main document as XMLPayload

XMLPayload xpld = msg.getDocument();

                // read XML Root node

                DocumentBuilderFactory factory;

                factory = DocumentBuilderFactory.newInstance();

                DocumentBuilder builder = factory.newDocumentBuilder();

Document document = builder.parse(xpld.getInputStream());

                String rootNode = document.getDocumentElement().getNodeName();

                Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"Root Node Name is " + rootNode );

if (rootNode.equals(rootNode1))

soapAction = createSOAPAction;

            

                else if (rootNode.equals(rootNode2))

soapAction = deleteSOAPAction;

                else if (rootNode.equals(rootNode3))

soapAction = modifySOAPAction;

                //setting Action in the message header

MessagePropertyKey action = new MessagePropertyKey("THeaderSOAPACTION","http://sap.com/xi/XI/System/SOAP"); 

                msg.setMessageProperty(action, soapAction);

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Soap action Set as " + soapAction );

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Soap action successfully set");

// Sets the principle data that represents usually the message to be processed

Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "Message Successfully updated");

inputModuleData.setPrincipalData(msg);

return inputModuleData;

          }

catch (Exception e) {

Audit.addAuditLogEntry(amk, AuditLogStatus.ERROR, "Message processing failed..");

ModuleException me = new ModuleException(e);

throw me;

}

    }

    /* (non-Javadoc)

     * @see javax.ejb.SessionBean#ejbActivate()

     */

     public void ejbActivate() throws EJBException, RemoteException {

     // TODO Auto-generated method stub

     }

     /* (non-Javadoc)

     * @see javax.ejb.SessionBean#ejbPassivate()

     */

     public void ejbPassivate() throws EJBException, RemoteException {

     // TODO Auto-generated method stub

     }

     /* (non-Javadoc)

     * @see javax.ejb.SessionBean#ejbRemove()

     */

     public void ejbRemove() throws EJBException, RemoteException {

     // TODO Auto-generated method stub

     }

     /* (non-Javadoc)

     * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)

     */

     public void setSessionContext(SessionContext context) throws EJBException,RemoteException {

     }

     /* (non-Javadoc)

     * @see javax.ejb.TimedObject#ejbTimeout(javax.ejb.Timer)

     */

     public void ejbTimeout(Timer arg0) {

     // TODO Auto-generated method stub

     }

     public void ejbCreate() throws javax.ejb.CreateException {

     }

}




1 Comment
Labels in this area