Пример #1
0
        public XmlDocument Send(XmlDocument message, MessageType messageType)
        {
            HttpWebRequest request = this.createWebRequest(message, messageType);

            ServicePointManager.Expect100Continue = true;
            ////ServicePointManager.SecurityProtocol = System.Security.Authentication.SslProtocols.Tls;
            ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback((sender, certificate, chain, sslPolicyErrors) => { return(true); });

            request.ClientCertificates.Add(this.settings.Certificate);
            using (Stream stream = request.GetRequestStream())
            {
                StreamWriter sw = new StreamWriter(stream, new System.Text.UTF8Encoding(false, true));
                message.Save(sw);
            }

            XmlDocument result = XmlHelperFunctions.CreateNewXmlDocument();

            using (WebResponse response = request.GetResponse())
            {
                using (StreamReader rd = new StreamReader(response.GetResponseStream()))
                {
                    string soapResult = rd.ReadToEnd();

                    result.LoadXml(soapResult);
                }
            }

            return(result);
        }
Пример #2
0
        public static Echo Create(string message, Settings settings)
        {
            string      xmlEcho = @"<?xml version='1.0' encoding='UTF-8'?><fu:EchoRequest xmlns:fu='http://www.fu.gov.si/' />";
            XmlDocument echoDoc = XmlHelperFunctions.CreateNewXmlDocument();

            echoDoc.LoadXml(xmlEcho);

            XmlNode xmlMessage = echoDoc.CreateTextNode(message);

            echoDoc.DocumentElement.AppendChild(xmlMessage);
            return(new Echo(echoDoc, settings));
        }
Пример #3
0
 public ReturnValue Send(string message)
 {
     try
     {
         XmlDocument xmlDoc = XmlHelperFunctions.CreateNewXmlDocument();
         xmlDoc.LoadXml(message);
         return(this.Send(xmlDoc));
     }
     catch (System.Exception ex)
     {
         return(ReturnValue.Error(SendingStep.MessageReceived, null, ex.Message));
     }
 }
Пример #4
0
        protected XmlDocument getXml(string fileName)
        {
            string fullName = this.getFullFileName(fileName);

            XmlDocument xml = XmlHelperFunctions.CreateNewXmlDocument();

            xml.Load(fullName);

            // It is important to set the tax number to match the one that is in certificate or else FURS will not proceed messages
            XmlNode nodeTaxNumber = xml.GetElementsByTagName("fu:TaxNumber")[0];

            if (nodeTaxNumber != null)
            {
                nodeTaxNumber.InnerText = MyTaxNumber;
            }

            return(xml);
        }
Пример #5
0
    public void SurroundWithSoap()
    {
      string emptySoap = string.Format(
        @"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' " +
         "                  xmlns:fu='{0}' " +
         "                  xmlns:xd='http://www.w3.org/2000/09/xmldsig#' " +
         "                  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> " +
         "    <soapenv:Header /> " +
         "    <soapenv:Body /> " +
         "</soapenv:Envelope>", this.Settings.FursXmlNamespace);

      this.MessageSendToFurs = XmlHelperFunctions.CreateNewXmlDocument();
      this.MessageSendToFurs.Schemas = this.Settings.Schemas;
      this.MessageSendToFurs.LoadXml(emptySoap);

      XmlNode body = this.MessageSendToFurs.ImportNode(this.Message.DocumentElement, true);
      XmlNode soapBody = XmlHelperFunctions.GetSubNode(this.MessageSendToFurs.DocumentElement, "soapenv:Body");
      soapBody.AppendChild(body);
    }