phax / phoss-smp

phoss SMP - a Peppol and OASIS BDXR SMP Server, CEF eDelivery compliant
125 stars 36 forks source link

Missing endpoint - Same document id and different process id #245

Closed francescodiperna closed 1 year ago

francescodiperna commented 1 year ago

Good morning, I have created the following endpoint:

Documenti id: urn:oasis:names:specification:ubl:schema:xsd:Order-2::Order##urn:fdc:peppol.eu:poacc:trns:order:3::2.1 Process id: urn:fdc:peppol.eu:poacc:bis:order_only:3

After that I create the endpoint:

Document id: urn:oasis:names:specification:ubl:schema:xsd:Order-2::Order##urn:fdc:peppol.eu:poacc:trns:order:3::2.1 Process id: urn:fdc:peppol.eu:poacc:bis:ordering:3

After this the first endpoint disappear, I do something wrong?

Maybe is wrong the method I use tu create endpoint:


public void AddEndpointToServiceGroup(ZenProvisioningConfiguration config, EndpointDto data) throws Exception {     
        final W3CEndpointReference START_AP_ENDPOINTREF = GetEndpointRef(data.ap_url);
        final String AP_CERT_STRING = config.getSmpServerCert();
        final String AP_SERVICE_DESCRIPTION = data.getService_description();
        final String AP_CONTACT_URL = data.getContact_url();
        final IProcessIdentifier PROCESS_ID = GetProcess(data.getProcess_id());
        final IDocumentTypeIdentifier DOCUMENT_ID = GetDocumentId(data.getDocument_id());
        final IParticipantIdentifier PARTICIPANT_ID = GetPartecipantId(data.getPeppol_id());                

        // Istanzio il client
        SMPClient smpClient = new SMPClient(URLHelper.getAsURI (config.getSmpServerUrl()));

        // Verifico prima se esiste il peppol id
        ServiceGroupType result = smpClient.getServiceGroupOrNull(PARTICIPANT_ID);
        if (result == null) {
            throw new SMPClientException("Cannot find peppol id " + PARTICIPANT_ID.toString());
        }

        // Definisco le credenziali di autenticazione
        final BasicAuthClientCredentials SMP_CREDENTIALS = new BasicAuthClientCredentials (config.getSmpServerUsername(), config.getSmpServerPassword());

        // Create the service registration
        final ServiceInformationType aServiceInformation = new ServiceInformationType ();
        {
          final ProcessListType aProcessList = new ProcessListType ();
          {
            final ProcessType aProcess = new ProcessType ();
            {
              final ServiceEndpointList aServiceEndpointList = new ServiceEndpointList ();
              {
                final EndpointType aEndpoint = new EndpointType ();
                aEndpoint.setEndpointReference (START_AP_ENDPOINTREF);
                aEndpoint.setTransportProfile (ESMPTransportProfile.TRANSPORT_PROFILE_PEPPOL_AS4_V2.getID ());
                aEndpoint.setCertificate (AP_CERT_STRING);
                //aEndpoint.setServiceActivationDate (PDTFactory.createXMLOffsetDateTime (2011, Month.JANUARY, 1));
                //aEndpoint.setServiceExpirationDate (PDTFactory.createXMLOffsetDateTime (2020, Month.DECEMBER, 31));
                aEndpoint.setServiceDescription (AP_SERVICE_DESCRIPTION);
                aEndpoint.setTechnicalContactUrl (AP_CONTACT_URL);
                //aEndpoint.setTechnicalInformationUrl (AP_INFO_URL);
                //aEndpoint.setMinimumAuthenticationLevel ("1");
                aEndpoint.setRequireBusinessLevelSignature (false);
                aServiceEndpointList.getEndpoint ().add (aEndpoint);
              }
              aProcess.setProcessIdentifier (new SimpleProcessIdentifier (PROCESS_ID));
              aProcess.setServiceEndpointList (aServiceEndpointList);
            }
            aProcessList.getProcess().add (aProcess);
          }
          aServiceInformation.setDocumentIdentifier (new SimpleDocumentTypeIdentifier (DOCUMENT_ID));
          aServiceInformation.setParticipantIdentifier (new SimpleParticipantIdentifier (PARTICIPANT_ID));
          aServiceInformation.setProcessList (aProcessList);          
        }
        smpClient.saveServiceInformation (aServiceInformation, SMP_CREDENTIALS);        
    }

Bye

phax commented 1 year ago

Hi @francescodiperna, this is (unfortunately) works as designed functionality. As also stated in https://github.com/phax/phoss-smp/wiki/REST-API#service-metadata-api - when you use the Endpoint REST API you always have to provide ALL the endpoints that are applicable to one participant for one document type.

francescodiperna commented 1 year ago

Thanks Philip, I solved :-)