phax / phase4

phase4 - AS4 client and server for integration into existing systems. Specific support for Peppol and CEF eDelivery built-in.
Apache License 2.0
154 stars 47 forks source link

Handling SMP lookup failed #248

Closed tonytram closed 2 months ago

tonytram commented 3 months ago

Hi @phax

I need help distinguishing between "Participant not existing" and "Participant not registered for this document type" in Phase4. The UnknownHostException, which could handle this, isn't accessible outside the SMPClient library. Any suggestions? Thanks for your help!

phax commented 2 months ago

Hi @tonytram, I was thinking this through and try to come up with a smart solution, but I failed. Therefore I suggest you use the following solution: Execute an SMP lookup aforehand and check before you call the builder, like this:

SMPClientReadOnly smpClient = new SMPClientReadOnly (...); // the same as you put in the builder
SignedServiceMetadataType serviceGroup = smpClient.getServiceGroupOrNull (aServiceGroupID);
if (serviceGroup == null) {
  // Participant not registered in the Peppol Network
} else {
  // Participant is registered
  // Trigger the AS4 sending
}

hth

tonytram commented 2 months ago

Hi Philip,

Thank you so much for your support. I will try this approach and get back to you.

Kind Regards

Tri Tram (Tony)

tonytram commented 2 months ago

Hi @phax,

I used ServiceGroupType instead because SignedServiceMetadataType caused a compile error. An extra request to check the availability of a given Participant might not be efficient.

To give you more context about our scenario, we're encountering cases where a lookup for a given ParticipantId fails during data transmission to Peppol. However, the Participant actually exists on the network. This issue might be due to latency or network lag.

Do you have any idea how we can make it more efficient?

Thank you,

phax commented 2 months ago

Yeah thanks. There is a bug in the code Well, there is also the opportunity that a receiver exists in the network but simply does not support the request document type or process. Indeed it does not add efficiency to perform another check, but that check is unavoidable. I will come up with a better and working test example to show that it can be done without an additional query...

phax commented 2 months ago

It took some time, but I think I found a suitable solution. With phase4 2.8.1 you can do the following code: https://github.com/phax/phase4/blob/master/phase4-peppol-client/src/test/java/com/helger/phase4/peppol/MainPhase4PeppolSenderNonExistingReceiver.java#L82

I was trying to find a better solution but failed - sorry.

Release will come soon

tonytram commented 2 months ago

Hi @phax , Thank you so much for your support. I will check the new release and come back to you if anything unclear. Really appreciate your work.