private void setOIHeader()
        {
            DeliveryInformation deliveryInfo = new DeliveryInformation();

            deliveryInfo.DocumentType = deliveryInfoDocType.IMAGEINVOICE;

            deliveryInfo.TrackingIdentifier    = new DeliveryInformationTrackingIdentifier[1];
            deliveryInfo.TrackingIdentifier[0] = new DeliveryInformationTrackingIdentifier();
            //deliveryInfo.TrackingIdentifier[0].indicatorSpecified = true;
            //deliveryInfo.TrackingIdentifier[0].indicator = DeliveryInformationTrackingIdentifierIndicator.correlationId;
            deliveryInfo.TrackingIdentifier[0].Value = mUniqueTrackingIdentifier;


            deliveryInfo.ReceiverIdentifier = new tradingPartnerIdType();
            deliveryInfo.ReceiverIdentifier.identifierType = tradingPartnerIdTypeIdentifierType.DUNSNumber;
            deliveryInfo.ReceiverIdentifier.Value          = "200103377";

            deliveryInfo.SenderIdentifier = new tradingPartnerIdType();
            deliveryInfo.SenderIdentifier.identifierType = tradingPartnerIdTypeIdentifierType.DUNSNumber;
            deliveryInfo.SenderIdentifier.Value          = mSupplierDunns;

            XmlSerializer           serializer = new XmlSerializer(typeof(DeliveryInformation));
            XmlSerializerNamespaces ns         = new XmlSerializerNamespaces();

            ns.Add("", "http://www.digitaloilfield.com/ocp");
            using (StringWriterUtf8 writer = new StringWriterUtf8())
            {
                serializer.Serialize(writer, deliveryInfo, ns);
                mOIHeader = writer.ToString();
            }
        }
        private void setSoapPayload()
        {
            XmlDocument payloadDoc = new XmlDocument();

            payloadDoc.LoadXml(mOIPayload);
            XmlDocument headerDoc = new XmlDocument();

            headerDoc.LoadXml(mOIHeader);

            //create the soap envelopoe
            Envelope soapEnvelope = new Envelope();
            Header   soapHeader   = new Header();

            soapEnvelope.Header = soapHeader;
            Body soapBody = new Body();

            soapEnvelope.Body = soapBody;

            //load the body:
            XmlDocument documentBody = new XmlDocument();

            documentBody.LoadXml("<DOReceiveSOAP xmlns=\"http://www.digitaloilfield.com/ocp\">" + payloadDoc.DocumentElement.OuterXml + "</DOReceiveSOAP>");
            soapBody.Any    = new XmlElement[1];
            soapBody.Any[0] = documentBody.DocumentElement;

            //load the header
            XmlDocument documentHeader = new XmlDocument();

            documentHeader.LoadXml("<DOHeaderSOAP xmlns=\"http://www.digitaloilfield.com/ocp\">" + headerDoc.DocumentElement.OuterXml + "</DOHeaderSOAP>");
            soapHeader.Any    = new XmlElement[1];
            soapHeader.Any[0] = documentHeader.DocumentElement;

            XmlSerializer           serializer = new XmlSerializer(typeof(Envelope));
            XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();

            namespaces.Add("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/");
            namespaces.Add("SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/");
            namespaces.Add("xsd", "http://www.w3.org/1999/XMLSchema");
            namespaces.Add("xsi", "http://www.w3.org/1999/XMLSchema-instance");

            using (StringWriterUtf8 writer = new StringWriterUtf8())
            {
                serializer.Serialize(writer, soapEnvelope, namespaces);
                mSoapPayload = writer.ToString();
            }
        }
        private void setOIPayloadFromInvoiceObject(Invoice invoiceObj)
        {
            XmlSerializer           serializer = new XmlSerializer(typeof(OpenImageInvoice));
            XmlSerializerNamespaces ns         = new XmlSerializerNamespaces();

            ns.Add("", "http://www.digitaloilfield.com/ocp");

            OpenImageInvoice invoice             = new OpenImageInvoice();
            OpenImageInvoiceInvoiceHeader header = new OpenImageInvoiceInvoiceHeader();

            header.InvoiceNumber = invoiceObj.invoiceNumber;

            header.Partner = new OpenImageInvoiceInvoiceHeaderPartner[2];

            // Buyer Company
            header.Partner[0] = new OpenImageInvoiceInvoiceHeaderPartner();
            header.Partner[0].PartnerTypeSpecified = true;
            header.Partner[0].PartnerType          = OpenImageInvoiceInvoiceHeaderPartnerPartnerType.Buyer;
            header.Partner[0].Company                = new OpenImageInvoiceInvoiceHeaderPartnerCompany();
            header.Partner[0].Company.CompanyCode    = new OpenImageInvoiceInvoiceHeaderPartnerCompanyCompanyCode[1];
            header.Partner[0].Company.CompanyCode[0] = new OpenImageInvoiceInvoiceHeaderPartnerCompanyCompanyCode();
            header.Partner[0].Company.CompanyCode[0].CompanyCodeType = OpenImageInvoiceInvoiceHeaderPartnerCompanyCompanyCodeCompanyCodeType.DUNSnumber;
            header.Partner[0].Company.CompanyCode[0].Value           = mSupplierDunns;
            header.Partner[0].DepartmentOrGroup = new departmentOrGroupType();
            header.Partner[0].DepartmentOrGroup.DepartmentCode = mSupplierDept;

            // Supplier Company
            header.Partner[1] = new OpenImageInvoiceInvoiceHeaderPartner();
            header.Partner[1].PartnerTypeSpecified = true;
            header.Partner[1].PartnerType          = OpenImageInvoiceInvoiceHeaderPartnerPartnerType.Supplier;
            header.Partner[1].Company                = new OpenImageInvoiceInvoiceHeaderPartnerCompany();
            header.Partner[1].Company.CompanyCode    = new OpenImageInvoiceInvoiceHeaderPartnerCompanyCompanyCode[1];
            header.Partner[1].Company.CompanyCode[0] = new OpenImageInvoiceInvoiceHeaderPartnerCompanyCompanyCode();
            header.Partner[1].Company.CompanyCode[0].CompanyCodeType = OpenImageInvoiceInvoiceHeaderPartnerCompanyCompanyCodeCompanyCodeType.VendorNumber;
            header.Partner[1].Company.CompanyCode[0].Value           = invoiceObj.companyCode;
            header.Partner[1].Company.CompanyName = invoiceObj.companyName;

            // Invoice Fields
            header.InvoiceDate = Convert.ToDateTime(invoiceObj.invoiceDate);
            header.InvoiceType = invoiceObj.invoiceType;
            header.Total       = Convert.ToDecimal(invoiceObj.invoiceTotal);

            // Tax Fields
            header.Tax    = new Tax[1];
            header.Tax[0] = new Tax();
            header.Tax[0].TotalSpecified = true;
            header.Tax[0].Total          = Convert.ToDecimal(invoiceObj.gstTotal);
            header.Tax[0].TaxType        = invoiceObj.taxType;

            // Currency
            header.CurrencyCode = invoiceObj.currencyCode;

            invoice.InvoiceHeader = header;

            // Attachment Reference
            invoice.AttachmentReference       = new OpenImageInvoiceAttachmentReference();
            invoice.AttachmentReference.href  = "cid:openImageAttachment" + mUniqueTrackingIdentifier;
            invoice.AttachmentReference.Value = mUniqueTrackingIdentifier;

            using (StringWriterUtf8 writer = new StringWriterUtf8())
            {
                serializer.Serialize(writer, invoice, ns);
                mOIPayload = writer.ToString();
            }
        }