phax / as2-lib

A generic Java AS2 library, servlet and server
107 stars 43 forks source link

Original message #150

Closed mayousheng closed 2 months ago

mayousheng commented 2 months ago

Dear Philip, I want to get the original message of AS2Message, how should I get it?

Thanks,

phax commented 2 months ago

What do you mean the "original" message? Do you mean a) the message how it is transmitted on the network level or b) the source message of an MDN?

mayousheng commented 2 months ago

Dear Philip,

I'm sorry I wasn't clear.

I want to get the http message information of as2 request. This should be a)

It should look something like this

` POST /as2/receive HTTP/1.1 Host: example.com User-Agent: MyAS2Client/1.0 Connection: keep-alive Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="----=_Part_123456_789123456.7891234567890" Content-Length: 12345 AS2-Version: 1.2 AS2-From: MyAS2SenderID AS2-To: MyAS2ReceiverID Message-ID: 1234567890@example.com Disposition-Notification-To: as2@example.com Disposition-Notification-Options: signed-receipt-protocol=optional, pkcs7-signature; signed-receipt-micalg=optional, sha-256 Recipient-Address: http://example.com/as2/receive Subject: AS2 Test Message MIME-Version: 1.0 Content-Transfer-Encoding: binary

------=_Part_123456_789123456.7891234567890 Content-Type: application/edi-x12 Content-Transfer-Encoding: binary Content-Disposition: attachment; filename="testfile.txt"

[File content omitted]

------=_Part_123456_789123456.7891234567890--

------=_Part_123456_789123456.7891234567891 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: binary Content-Disposition: attachment; filename="smime.p7s"

[Signature content omitted]

------=_Part_123456_789123456.7891234567891-- `

mayousheng commented 2 months ago

The following lines in the AS2SenderModulecaught my attention. Perhaps I can find the desired message here?

Snipaste_2024-07-02_00-48-18

phax commented 2 months ago

I added the interfaces IHTTPOutgoingDumper and IHTTPIncomingDumper to exactly perform these issues. For sending messages, you can provide these dumpers via the AS2ClientSettings class. For receiving, you need to adopt the AS2ReceiveXServlet.... handler accordingly (or set the dumper globally via HTTPHelper.setHTTPIncomingDumperFactory)

mayousheng commented 2 months ago

ok, I tried it this way and it worked for me. Thank you for your help