on 01-24-2017 12:32 PM
Hello experts - I'm looking for some guidance.
I have a File to SOAP async scenario.
I'm facing 2 issues:
I assume the xlink:href should be "cid:COB04113.REM" for the example above.
When a message is sent through, there is no failure and the SOAP call seems to complete succesfully, but I believe the receiver WS is not accepting or discarding the sent attached file as the file name does not match the attachment content ID value.
What suggestions do you have?
Thank you
Elison
Details:
Message Mapping target structure
I'm using ASMA to get the filename and building the content field as "cid:[filename]". Constant for the destination.
After the XSLT mapping I get the following message structure, which is correct:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>user</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText
">password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ns1:uploadFile xmlns:ns1="urn:ServiceWS">
<file>
<filename>COB04113.REM</filename>
<content>cid:COB04113.REM</content>
</file>
<destination>INBOX</destination>
</ns1:uploadFile>
</soapenv:Body>
</soapenv:Envelope>
Details:
Bean for custom adapter module to create the attached file (credits amitsrivastava5)
/**
*
*/
package com.sap.adaptermodule;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
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.Payload;
import com.sap.engine.interfaces.messaging.api.XMLPayload;
import com.sap.engine.interfaces.messaging.api.auditlog.AuditLogStatus;
/**
* @author amitsrivastava5
*
*/
public class SavePayloadBean implements SessionBean {
/* (non-Javadoc)
* @see javax.ejb.SessionBean#ejbActivate()
*/
@Override
public void ejbActivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#ejbPassivate()
*/
@Override
public void ejbPassivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#ejbRemove()
*/
@Override
public void ejbRemove() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
*/
@Override
public void setSessionContext(SessionContext arg0) throws EJBException,
RemoteException {
// TODO Auto-generated method stub
}
public void ejbCreate() throws javax.ejb.CreateException {
}
public ModuleData process(ModuleContext mc, ModuleData inputModuleData)
throws ModuleException {
Object obj = null;
Message msg = null;
MessageKey key = null;
String FileName = "";
MessagePropertyKey FileKey = null;
try {
obj = inputModuleData.getPrincipalData();
msg = (Message) obj;
key = new MessageKey(msg.getMessageId(), msg.getMessageDirection());
FileKey = new MessagePropertyKey("FileName", "http://sap.com/xi/XI/System/File");
// getting FileName from ASMA parameters
FileName = msg.getMessageProperty(FileKey);
// Returns the main document as XMLPayload.
XMLPayload xpld = msg.getDocument();
byte[] inpbyt = xpld.getContent();
Audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS, "Input file read successfully");
//Archiving target file on FTP server
xpld.setContent(inpbyt);
Payload ftpFilePayload = msg.createPayload();
ftpFilePayload.setName(FileName);
ftpFilePayload.setContentType("text/plain;charset = \"UTF-8\"");
ftpFilePayload.setContent(inpbyt);
ftpFilePayload.setDescription("Attachment");
msg.addAttachment(ftpFilePayload);
// Sets the principle data that represents usually the message to be processed
inputModuleData.setPrincipalData(msg);
}catch (Exception e) {
Audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS, "Module Exception caught:");
ModuleException me = new ModuleException(e);
throw me;
}
return inputModuleData;
}
}
XSLT code for wsse Security to authenticate the soap call at the receiver WS.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:ServiceWS"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" />
<xsl:attribute-set name="attr-soap">
<xsl:attribute name="soapenv:mustUnderstand">1</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="attr-pasw">
<xsl:attribute name="Type">http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText
</xsl:attribute>
</xsl:attribute-set>
<xsl:template match="/">
<soapenv:Envelope>
<soapenv:Header>
<xsl:element name="wsse:Security"
use-attribute-sets="attr-soap">
<xsl:element name="wsse:UsernameToken">
<xsl:element name="wsse:Username">user</xsl:element>
<xsl:element name="wsse:Password" use-attribute-sets="attr-pasw">password</xsl:element>
</xsl:element>
</xsl:element>
</soapenv:Header>
<soapenv:Body>
<xsl:copy-of select="*"/>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
</xsl:stylesheet>
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.