cancel
Showing results for 
Search instead for 
Did you mean: 

How to set parameters in Module config for "Set Attachment Name" Module

peter_wallner2
Active Contributor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

peter_wallner2
Active Contributor
0 Kudos

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

peter_wallner2
Active Contributor
0 Kudos

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:

http://wiki.sdn.sap.com/wiki/display/XI/Adapter%20Module%20PI%207.0%20Set%20Attachment%20Name?bc=tru...

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

stefan_grube
Active Contributor
0 Kudos

Hi Peter,

I think it should be:

payload.setContentType("text/plain;charset = \"UTF-8\";"
                               + "name=\"" + fileName + "\"");

Could you have a try?

Regards

Stefan

peter_wallner2
Active Contributor
0 Kudos

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

stefan_grube
Active Contributor
0 Kudos

> Thank you very much for your help - that was it - now it works!!

Fine. I changed the code in the WIKI. It seems that are the first who used it

Answers (1)

Answers (1)

Former Member
0 Kudos

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

peter_wallner2
Active Contributor
0 Kudos

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 + "\"");

Former Member
0 Kudos

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

peter_wallner2
Active Contributor
0 Kudos

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:

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f013e82c-e56e-2910-c3ae-c602a67b9...

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?

Former Member
0 Kudos

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_wallner2
Active Contributor
0 Kudos

Hello Christophe,

Just one quick question.

What do you mean by:


Also, could you add tcpgw b/w your PI and target system

Thank you for your explanation.

Best regards,

Peter

Former Member
0 Kudos

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