示例#1
0
        /// <summary>
        /// Send metadata to create a message
        /// </summary>
        public string Send(IMessageMetadata metadata, XmlDocument body)
        {
            try
            {
                STARTLibrary.accesspointService.Create messageBody = new STARTLibrary.accesspointService.Create();
                messageBody.Any = new XmlElement[] { body.DocumentElement };

                var request = new STARTLibrary.accesspointService.CreateRequest
                {
                    MessageIdentifier   = metadata.MessageIdentifier,
                    ChannelIdentifier   = metadata.ChannelIdentifier,
                    RecipientIdentifier = metadata.RecipientIdentifier,
                    SenderIdentifier    = metadata.SenderIdentifier,
                    DocumentIdentifier  = metadata.DocumentIdentifier,
                    ProcessIdentifier   = metadata.ProcessIdentifier,
                    Create = messageBody
                };

                return(common.Utilities.CallCreate(resourceFactory, thisUri, smlDomain, assuranceLevel, request));
            }
            catch (Exception)
            {
                throw help.MakePeppolException("bden:ServerError", "ServerError");
            }
        }
示例#2
0
        private static CreateRequest GenerateTestRequest(XmlDocument xml, string sender, string receiver)
        {
            const string businessIdScheme       = "iso6523-actorid-upis";             //trur denne bestemmer at vi skal bruke norsk standard på sender og mottaker-id. Usikker på kva "u"-en gjær..
            const string businessIdSchemeSender = "iso6523-actorid-upis";             //med ein ekstra u (samme som eksempel i pdf fra difi)
            const string documentIdScheme       = "busdox-docid-qns";                 //denne er fast!
            string       documentIdValue        = PeppolDocumentType.InvoicePeppol4a; //"urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:www.cenbii.eu:transaction:biicoretrdm010:ver1.0:#urn:www.peppol.eu:bis:peppol5a:ver1.0:#urn:www.difi.no:ehf:faktura:ver1::2.0"; //norsk EHF efaktura 2.0 trur eg
            string       processIdValue         = PeppolProcessType.Bii04V1;          //"urn:www.cenbii.eu:profile:bii05:ver1.0"; //processId identifiserer den prosess forretningsdokumentet er en del av. bii04 == kun faktura,  bii05 == faktura og kreditnota
            const string processIdScheme        = "cenbii-procid-ubl";                //denne er fast!

            //Metadata for dokumentet som skal sendes
            IMessageMetadata metadata = new MessageMetadata()
            {
                RecipientIdentifier = new ParticipantIdentifierType {
                    Value = receiver.ToLower(), scheme = businessIdScheme
                },
                SenderIdentifier = new ParticipantIdentifierType {
                    Value = sender.ToLower(), scheme = businessIdSchemeSender
                },
                DocumentIdentifier = new DocumentIdentifierType {
                    Value = documentIdValue, scheme = documentIdScheme
                },
                ProcessIdentifier = new ProcessIdentifierType {
                    Value = processIdValue, scheme = processIdScheme
                },
                ChannelIdentifier = EHFUtility.DefaultChannel,
                MessageIdentifier = "uuid:" + Guid.NewGuid().ToString("D")
            };

            var messageBody = new STARTLibrary.accesspointService.Create {
                Any = new[] { xml.DocumentElement }
            };

            var createRequest = new STARTLibrary.accesspointService.CreateRequest
            {
                MessageIdentifier   = metadata.MessageIdentifier,
                ChannelIdentifier   = metadata.ChannelIdentifier,
                RecipientIdentifier = metadata.RecipientIdentifier,
                SenderIdentifier    = metadata.SenderIdentifier,
                DocumentIdentifier  = metadata.DocumentIdentifier,
                ProcessIdentifier   = metadata.ProcessIdentifier,
                Create = messageBody
            };

            return(createRequest);
        }
示例#3
0
        /// <summary>
        /// Super-simple method to send a EHF-invoice
        /// </summary>
        /// <param name="xmlDocument">EHF-document to send</param>
        /// <param name="sender">sender-id, sample:9908:974763907</param>
        /// <param name="receiver">receiver-id, sample:9908:974763907</param>
        /// <param name="documentType">See <see cref="PeppolDocumentType"/></param>
        /// <param name="processType"></param>
        /// <returns>Returns a <see cref="SendResult"/> containing the unique ID of the sent message and response from access-point-service. If message is not sent, an exception is thrown </returns>
        public SendResult SendDocument(XmlDocument xmlDocument, string sender, string receiver, string documentType, string processType)
        {
            Log.Info("Start send invoice...");
            var start = DateTime.Now;

            if (xmlDocument == null || xmlDocument.DocumentElement == null)
            {
                throw new Exception("xmlDocument was null or xmlDocument.DocumentElement was null, aborting send..");
            }
            if (string.IsNullOrEmpty(sender))
            {
                throw new ArgumentNullException("sender", "sender cannot be null. samlpevalue: 9908:974763907");
            }
            if (string.IsNullOrEmpty(receiver))
            {
                throw new ArgumentNullException("receiver", "receiver cannot be null. samlpevalue: 9908:974763907");
            }

            //Faste verdier for EHF faktura 2.0:
            const string businessIdScheme       = "iso6523-actorid-upis";                //trur denne bestemmer at vi skal bruke norsk standard på sender og mottaker-id. Usikker på kva "u"-en gjær..
            const string businessIdSchemeSender = "iso6523-actorid-upis";                //med ein ekstra u (samme som eksempel i pdf fra difi)
            string       documentIdScheme       = PeppolDocumentType.DocumentTypeSchema; //"busdox-docid-qns"; //denne er fast!
            string       processIdScheme        = PeppolProcessType.ProcessIdSchema;


            //variable verdier avhengig av dokument:
            var documentIdValue = documentType;
            var processIdValue  = processType;//processId identifiserer den prosess forretningsdokumentet er en del av. bii04 == kun faktura,  bii05 == faktura og kreditnota

            //Metadata for dokumentet som skal sendes
            IMessageMetadata metadata = new MessageMetadata()
            {
                RecipientIdentifier = new ParticipantIdentifierType {
                    Value = receiver.ToLower(), scheme = businessIdScheme
                },
                SenderIdentifier = new ParticipantIdentifierType {
                    Value = sender.ToLower(), scheme = businessIdSchemeSender
                },
                DocumentIdentifier = new DocumentIdentifierType {
                    Value = documentIdValue, scheme = documentIdScheme
                },
                ProcessIdentifier = new ProcessIdentifierType {
                    Value = processIdValue, scheme = processIdScheme
                },
                ChannelIdentifier = DefaultChannel,
                MessageIdentifier = "uuid:" + Guid.NewGuid().ToString("D")
            };

            var messageBody = new STARTLibrary.accesspointService.Create {
                Any = new[] { xmlDocument.DocumentElement }
            };

            var createRequest = new STARTLibrary.accesspointService.CreateRequest
            {
                MessageIdentifier   = metadata.MessageIdentifier,
                ChannelIdentifier   = metadata.ChannelIdentifier,
                RecipientIdentifier = metadata.RecipientIdentifier,
                SenderIdentifier    = metadata.SenderIdentifier,
                DocumentIdentifier  = metadata.DocumentIdentifier,
                ProcessIdentifier   = metadata.ProcessIdentifier,
                Create = messageBody
            };

            Log.InfoFormat("Message {0} created OK", metadata.MessageIdentifier);

            var serviceMetadata = GetServiceMetadataFromSML(createRequest);

            var result     = SendDocument(createRequest, sender, receiver, serviceMetadata);
            var timerTotal = DateTime.Now.Subtract(start);

            result.TimeSpent = timerTotal;
            return(result);
        }