on 05-04-2011 8:18 AM
Dear experts,
I have implemented the adapter module to set the attachment name in a ZIP archive.
Recommended in blog: /people/stefan.grube/blog/2007/02/20/working-with-the-payloadzipbean-module-of-the-xi-adapter-framework
I used this java code for the module: http://wiki.sdn.sap.com/wiki/display/XI/AdapterModulePI7.0SetAttachmentName
I deployed it and set the following parameters in the module configuration:
Sequence:
localejbs/SetAttachmentName Local Enterprise Bean name
AF_Modules/PayLoadZipBean Local Enterprise Bean zip
CallSapAdapter Local Enterprise Bean 0
Module configuration
zip zip.filenameKey contentType
zip zip.mode zipOne
name name.FileName FileName
Now when testing with a message in RWB --> Message Monitoring --> Audit protocoll I get the info:
"MP: Local Module localejbs/SetAttachmentName being processed"
So the module is being processed but the file name in the ZIP archive is "untitled.xml".
Do you know how I have to set the parameters for my SetAttachmentName module? I also tried in Module configuration not to set anything but that did not work either.
Thank you for any help and best regards,
Peter
Hi Peter,
I'm facing the same issue. So my question would be, what parameters did you finally set in your module configuration? How did you solve your problem?
Thank you in advance for your help and best regards,
Kamran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Kamran,
No, unfortunately I have not figured that out yet. It is not priority number 1 for me so I have not tried around for a while. I did try a lot of different settings but somehow the name does not get passed to my java code.
In case you have any good news I would appreciate if you could post your solution here.
Thank you and best regards,
Peter
Dear experts,
I am trying again to solve this issue.
I am trying to set the filename of a file in a ZIP archive. I have created an Adapter Module and used this code:
I have created the module and with the help of Netweaver Development Studio I was able to debug it.
I saw in the debug mode that "fileName" is filled with the ASMA value it gets.
But something is not right in my adapter module configuration
localejbs/SetAttachmentName Local Enterprise Bean name
AF_Modules/PayloadZipBean Local Enterprise Bean zip
CallSapAdapter Local Enterprise Bean 0
and
zip zip.filenameKey contentType
zip zip.mode zipOne
But the filename in my ZIP Archive is always "untitled.txt". So my conclusion is that the PayloadZipBean is not getting the ContentType I set in my SetAttachmentName module.
Does anyone have experience with that or know how to set the module configuration - Thank you!
Best regards,
Peter
Hello Stefan,
Thank you very much for your help - that was it - now it works!! I additionally changed the coding to:
double randNumber = Math.random() * 1000;
if(fileName == null){
fileName="default.txt";
}
else{
fileName=fileName + "_" + randNumber + ".xml";
}
payload.setContentType("text/plain;charset = \"UTF-8\";"
+ "name=\"" + fileName + "\"");
in order to generate a unique filename with the generated number.
Best regards,
Peter
Peter,
According to the adapter JAVA code, it expects to find the target name in the message properties (FileName) ... Is this property correctly set in the message (ASMA ? ) ? Normally, when this prop is not found, the name should become "default.txt", whereas you seem to get "untitled.xml", meaning it could be derived from a static FileName property from the FCC adapter ?
Rgds
Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Christophe,
In the File Receiver adapter I activated adapter specific attributes and checked "Filename". In MONI when I look under
DynamicConfiguration it gives me the line
<SAP:Record namespace="http://sap.com/xi/XI/System/File" name="FileName">MiImport104-201105040850-.zip</SAP:Record>
So the name is there and is also being used to name the ZIP archive - just the file inside is called "untitled.xml". You are right - it should be "default.txt". That means the Java code finds a name but then does not use it!?
I have no static file name set in the Receiver channel.
Thank you for any further hints!
Best regards,
Peter
Edited by: Peter Wallner on May 4, 2011 10:25 AM
Christophe,
Do I need to call "setContentType" somehow in the Module configuration?
payload.setContentType("text/plain;charset = \"UTF-8\";"
+ "filename=\"" + fileName + "\"");
Strange indeed !
I can't remember what AFW module offers in terms of debugging, but you could try setting the filename statically in the JAVA code and see if at least the attachment is renamed (meaning it's "only" a matter of getting the attribute) ... The best way would be debugging the module though !
the setContentType method may need some change if the corresponding content is not always a text/plain (though I'm not sure) ?
Chris
PS : in Stefan's blog, he uses name (instead of filename) in the contentType attribute and in the Zip module online help, it also refers to "name" ... Try adjusting the module code and see if it works ?
Edited by: Christophe PFERTZEL on May 4, 2011 10:59 AM
Edited by: Christophe PFERTZEL on May 4, 2011 11:21 AM
Hello Christophe,
I changed my JAVA code to:
//String fileName = msg.getMessageProperty("http://sap.com/xi/XI/System/File",
//"FileName");
String fileName = "dateiname.xml";
payload.setContentType("text/xml;charset = \"UTF-8\";"
+ "filename=\"" + fileName + "\"");
and also added the XML code from page 10:
for logging.
The name in the ZIP archive is still "untitled.xml". And what is funny is that in RWB --> Audit Log the only entry concerning my module is:
"MP: Local Modul localejbs/SetAttachmentName processed"
Normally when a Module gets processed another 1 or 2 steps are listed. It is as if nothing in the Module gets excecuted.
I will play around with the configuration parameters.
Thank you for your help,
Peter
Edited by: Peter Wallner on May 4, 2011 1:47 PM
Would you know by any chance where I can look at the logging information?
Peter,
Normally, if you want additional entries to appear in the AFW audit logs, you need to explictly add the corresponding code to your module source code ! Anyway, what you've done shows it does nothing at all ... Have you tried moving from "filename" to "name" for the content-type header ? Because if the zip bean expects "name" and you set "filename", this could explain the "untitled.xml" file name that could be defaulted by it (hope I'm clear ?) ...
Also, could you add tcpgw b/w your PI and target system, so you can watch the HTTP data/headers flow during the msg exchange
Chris
Edited by: Christophe PFERTZEL on May 4, 2011 2:42 PM
Peter,
tcpgw is a small TCP sniffing tool SAP offers to investigate at TCP layer level ! You can watch/analyse traffic (request/response headers, body) between our adapter and its target, like this
PI -> SOAP adapter (or any HTTP based adapter) -> host running TCPGW on a listen port you've chosen -> TCPGW redirects traffic to the corresponding target URL
If you search SAPNet or SDN for "tcpgw", I think you will find the documentation
Rgds
Chris
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.