private static void Serialize(SoapHeader soapHeader, XmlDocument document, XmlNode root)
        {
            if (soapHeader == null)
            {
                throw new ArgumentNullException(nameof(soapHeader));
            }

            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }

            var headerNode = document.CreateElement(Constants.XmlPrefixes.SoapEnv, Constants.XmlRootNames.SoapHeader, Constants.XmlNamespaces.SoapEnvelope);

            if (soapHeader.Security != null)
            {
                Serialize(soapHeader.Security, document, headerNode);
            }

            root.AppendChild(headerNode);
        }
        /// <summary>
        /// Read data from the the general ledger.
        /// </summary>
        /// <param name="requestOptions">The request options.</param>
        /// <returns></returns>
        public async Task <GeneralLedgerData> GetGeneralLedgerData(List <GeneralLedgerRequestOption> requestOptions)
        {
            var requestString          = GeneralLedgerRequestOptionsParser.Parse(requestOptions);
            var balanceSheetDataResult = await SoapClient.ProcessXmlDocumentAsync(
                await SoapHeader.GetHeaderAsync(new Header()),
                requestString.ToXmlNode()
                );

            var balanceSheetHeaders  = new Dictionary <string, TwinfieldDataLineHeader>();
            var balanceSheetDataList = new List <List <TwinfieldDataLine> >();
            var firstNode            = true;

            foreach (XmlNode row in balanceSheetDataResult.ProcessXmlDocumentResult)
            {
                if (firstNode)
                {
                    foreach (XmlNode el in row.ChildNodes)
                    {
                        if (el.Name.Equals("td"))
                        {
                            balanceSheetHeaders[el.InnerText] = new TwinfieldDataLineHeader()
                            {
                                ValueType = el.Attributes["type"]?.Value,
                                Label     = el.Attributes["label"]?.Value
                            };
                        }
                    }

                    firstNode = false;
                }
                else
                {
                    var rowData = new List <TwinfieldDataLine>();
                    foreach (XmlNode el in row)
                    {
                        if (el.Name.Equals("td"))
                        {
                            rowData.Add(new TwinfieldDataLine()
                            {
                                Field = el.Attributes["field"]?.Value,
                                Label = balanceSheetHeaders[el.Attributes["field"]?.Value]?.Label,
                                Value = new TwinfieldValue(balanceSheetHeaders[el.Attributes["field"]?.Value]?.ValueType, el.InnerText)
                            });
                        }
                    }

                    balanceSheetDataList.Add(rowData);
                }
            }

            return(new GeneralLedgerData()
            {
                Headers = balanceSheetHeaders,
                Data = balanceSheetDataList
            });
        }
Esempio n. 3
0
        public SoapEnvelope Build()
        {
            CheckInit();
            var samlAssertionId = GenerateId("assertion");
            var requestId       = GenerateId("request");
            var bodyId          = GenerateId("id");
            var timeStampId     = GenerateId("TS");
            var x509Id          = GenerateId("X509");
            var ssin            = GetSsin(_x509Certificate.Subject);

            if (string.IsNullOrWhiteSpace(ssin))
            {
                throw new EhealthException(Constants.ErrorCodes.NoSerialNumber);
            }

            var identitySubject = ParseSubject(_x509Certificate.Subject);
            var issuerSubject   = ParseSubject(_x509Certificate.Issuer);

            _samlAttributes.Add(new SamlAttribute(Constants.EhealthStsNames.SsinCertHolderAttributeName, Constants.EhealthStsNames.SsinAttributeNamespace, ssin));
            _samlAttributes.Add(new SamlAttribute(Constants.EhealthStsNames.SsinAttributeName, Constants.EhealthStsNames.SsinAttributeNamespace, ssin));
            _samlAttributeDesignators.Add(new SamlAttributeDesignator(Constants.EhealthStsNames.SsinCertHolderAttributeName, Constants.EhealthStsNames.SsinAttributeNamespace));
            _samlAttributeDesignators.Add(new SamlAttributeDesignator(Constants.EhealthStsNames.SsinAttributeName, Constants.EhealthStsNames.SsinAttributeNamespace));
            var issueInstant       = DateTime.Now;
            var samlNameIdentifier = new SamlNameIdentifier(
                Constants.EhealthStsNames.NameIdentifierFormat,
                issuerSubject,
                identitySubject);
            var samlSubject             = new SamlSubject(samlNameIdentifier);
            var samlConditions          = new SamlConditions(issueInstant);
            var samlAttributeStatement  = new SamlAttributeStatement(samlSubject, _samlAttributes);
            var samlAssertion           = new SamlAssertion(samlAssertionId, issueInstant, identitySubject, samlConditions, samlAttributeStatement);
            var subjectConfirmationData = new SamlSubjectConfirmationData(samlAssertion);
            var subjectConfirmation     = new SamlSubjectConfirmation(Constants.EhealthStsNames.SubjectConfirmationMethod, _x509Certificate, subjectConfirmationData);
            var samlSubjectO            = new SamlSubject(samlNameIdentifier, subjectConfirmation);
            var samlAttributeQuery      = new SamlAttributeQuery(samlSubjectO, _samlAttributeDesignators);
            var samlRequest             = new SamlRequest(requestId, samlAttributeQuery);
            var body         = new SoapBody(samlRequest, bodyId);
            var soapSecurity = new SoapSecurity(DateTime.UtcNow, timeStampId, x509Id, _x509Certificate);
            var header       = new SoapHeader(soapSecurity);
            var soapEnvelope = new SoapEnvelope(header, body);

            return(soapEnvelope);
        }
        /// <summary>
        /// Gets the office list from Twinfield.
        /// </summary>
        /// <returns></returns>
        public async Task <List <Office> > GetOfficeList()
        {
            var document         = "<list><type>offices</type></list>";
            var officeListResult = await SoapClient.ProcessXmlDocumentAsync(
                await SoapHeader.GetHeaderAsync(new Header()),
                document.ToXmlNode()
                );

            var result = new List <Office>();

            foreach (XmlNode node in officeListResult.ProcessXmlDocumentResult.ChildNodes)
            {
                result.Add(new Office()
                {
                    Code      = node.InnerText,
                    Name      = node.Attributes["name"]?.Value,
                    ShortName = node.Attributes["shortname"]?.Value
                });
            }

            return(result);
        }
        /// <summary>
        /// Gets the general ledger request options.
        /// </summary>
        /// <param name="companyCode">The company code.</param>
        /// <returns></returns>
        public async Task <List <GeneralLedgerRequestOption> > GetGeneralLedgerRequestOptions(string companyCode)
        {
            var document           = $"<read><type>browse</type><code>030_2</code><office>{companyCode}</office></read>";
            var dataRequestOptions = await SoapClient.ProcessXmlDocumentAsync(
                await SoapHeader.GetHeaderAsync(new Header()),
                document.ToXmlNode()
                );

            var result = new List <GeneralLedgerRequestOption>();

            foreach (XmlNode node in dataRequestOptions.ProcessXmlDocumentResult.LastChild.ChildNodes)
            {
                var glro = new GeneralLedgerRequestOption()
                {
                    Id = node.Attributes["id"]?.Value
                };

                foreach (XmlNode childElement in node.ChildNodes)
                {
                    switch (childElement.Name)
                    {
                    case "label": glro.Label = childElement.InnerText; break;

                    case "field": glro.Field = childElement.InnerText; break;

                    case "operator": glro.Operator = childElement.InnerText; break;

                    case "visible": glro.Visible = childElement.InnerText.Equals("true"); break;

                    case "ask": glro.Ask = childElement.InnerText.Equals("true"); break;
                    }
                }

                result.Add(glro);
            }

            return(result);
        }
        /// <summary>
        /// Gets the fields for either a Balance Sheet or Profit and Loss.
        /// </summary>
        /// <param name="companyCode">The company code.</param>
        /// <param name="financialType">Type of the dim. BAS for Balance Sheet, PNL for Profit and Loss</param>
        /// <returns></returns>
        private async Task <Dictionary <string, string> > GetFields(string companyCode, string financialType)
        {
            var searchRequest = new SearchRequest()
            {
                Header   = await SoapHeader.GetHeaderAsync(new Header()),
                type     = "DIM",
                pattern  = "*",
                field    = 0,
                firstRow = 1,
                maxRows  = int.MaxValue,
                options  = new[]
                {
                    new [] { "section", "financials" },
                    new [] { "dimtype", financialType },
                    new [] { "office", companyCode }
                }
            };
            var searchResults = await SoapClient.SearchAsync(searchRequest);

            return(searchResults.data.Items
                   .Select(s => new { Code = s[0], Name = s[1] })
                   .ToDictionary(d => d.Code, d => d.Name));
        }
        public XmlDocument Serialize <T>(T request, XmlElement assertionNode) where T : RequestType
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var    serialzer = new XmlSerializer(typeof(T));
            string xml;

            using (var strW = new StringWriter())
            {
                using (var writer = XmlWriter.Create(strW))
                {
                    serialzer.Serialize(writer, request);
                    xml = strW.ToString();
                }
            }

            var doc = new XmlDocument();

            doc.LoadXml(xml);
            var          soapBody     = new SoapBody(doc.DocumentElement);
            SoapSecurity soapSecurity = null;

            if (assertionNode != null)
            {
                soapSecurity = new SoapSecurity(assertionNode);
            }

            var soapHeader   = new SoapHeader(soapSecurity);
            var soapEnvelope = new SoapEnvelope(soapHeader, soapBody);
            var serializer   = new SoapMessageSerializer();

            return(serializer.Serialize(soapEnvelope));
        }
 public void Insert(int index, SoapHeader header)
 {
 }
 public void Remove(SoapHeader header)
 {
 }
 public void CopyTo(SoapHeader[] array, int index)
 {
 }
 public int IndexOf(SoapHeader header)
 {
 }
Esempio n. 12
0
        /// <summary>   
        /// 调用WebService
        /// </summary>   
        /// <param name="wsUrl">WebService地址</param>   
        /// <param name="className">类名</param>   
        /// <param name="methodName">方法名称</param>   
        /// <param name="soapHeader">SOAP头</param>
        /// <param name="args">参数列表</param>   
        /// <returns>返回调用结果</returns>   
        public static object InvokeWebService(string wsUrl, string className, string methodName, SoapHeader soapHeader, object[] args)
        {
            string @namespace = "receive.blf.jcms";
            if ((className == null) || (className == ""))
            {
                className = GetWsClassName(wsUrl);
            }
            try
            {
                //获取WSDL
                WebClient wc = new WebClient();
                Stream stream = wc.OpenRead(wsUrl + "?wsdl");
                ServiceDescription sd = ServiceDescription.Read(stream);
                ServiceDescriptionImporter sdi = new ServiceDescriptionImporter();
                sdi.AddServiceDescription(sd, "", "");
                CodeNamespace cn = new CodeNamespace(@namespace);

                //生成客户端代理类代码
                CodeCompileUnit ccu = new CodeCompileUnit();
                ccu.Namespaces.Add(cn);
                sdi.Import(cn, ccu);
                CSharpCodeProvider csc = new CSharpCodeProvider();
                ICodeCompiler icc = csc.CreateCompiler();

                //设定编译参数
                CompilerParameters cplist = new CompilerParameters();
                cplist.GenerateExecutable = false;
                cplist.GenerateInMemory = true;
                cplist.ReferencedAssemblies.Add("System.dll");
                cplist.ReferencedAssemblies.Add("System.XML.dll");
                cplist.ReferencedAssemblies.Add("System.Web.Services.dll");
                cplist.ReferencedAssemblies.Add("System.Data.dll");

                //编译代理类
                CompilerResults cr = icc.CompileAssemblyFromDom(cplist, ccu);
                if (true == cr.Errors.HasErrors)
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    foreach (System.CodeDom.Compiler.CompilerError ce in cr.Errors)
                    {
                        sb.Append(ce.ToString());
                        sb.Append(System.Environment.NewLine);
                    }
                    throw new Exception(sb.ToString());
                }

                //生成代理实例,并调用方法
                System.Reflection.Assembly assembly = cr.CompiledAssembly;
                Type t = assembly.GetType(@namespace + "." + className, true, true);

                FieldInfo[] arry = t.GetFields();

                FieldInfo client = null;
                object clientkey = null;
                if (soapHeader != null)
                {
                    //Soap头开始
                    client = t.GetField(soapHeader.ClassName + "Value");
                    //获取客户端验证对象
                    Type typeClient = assembly.GetType(@namespace + "." + soapHeader.ClassName);
                    //为验证对象赋值
                    clientkey = Activator.CreateInstance(typeClient);
                    foreach (KeyValuePair<string, object> property in soapHeader.Properties)
                    {
                        typeClient.GetField(property.Key).SetValue(clientkey, property.Value);
                    }
                    //Soap头结束
                }

                //实例类型对象
                object obj = Activator.CreateInstance(t);
                if (soapHeader != null)
                {
                    //设置Soap头
                    client.SetValue(obj, clientkey);
                }

                System.Reflection.MethodInfo mi = t.GetMethod(methodName);
                return mi.Invoke(obj, args);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
                //throw new Exception(ex.InnerException.Message, new Exception(ex.InnerException.StackTrace));
            }
        }
Esempio n. 13
0
        public void WebServiceInvoke()
        {
            TestCase btc = new TestCase();

            btc.Name           = "Serialization Test";
            btc.Description    = "Test to blah blah blah, yeah really!";
            btc.BizUnitVersion = "4.0.0.1";

            var ws = new WebServiceStep();

            ws.Action = "http://schemas.virgin-atlantic.com/AncillarySales/Book/Services/2009/IAncillarySalesBook/GetProductTermsAndConditions";
            FileDataLoader dataLoader;

            dataLoader          = new FileDataLoader();
            dataLoader.FilePath = @"..\..\..\Test\BizUnit.TestSteps.Tests\TestData\GetProductTermsAndConditions_RQ.xml";
            ws.RequestBody      = dataLoader;
            ws.ServiceUrl       = "http://localhost/AncillarySalesBook/AncillarySalesBook.svc";
            ws.Username         = @"newkydog001\kevinsmi";
            var header = new SoapHeader();

            header.HeaderName      = "ServiceCallingContext";
            header.HeaderNameSpace = "http://schemas.virgin-atlantic.com/Services/ServiceCallingContext/2009";

            var ctx = new ServiceCallingContext();

            ctx.ApplicationName         = "BVT Tests";
            ctx.GUid                    = "{1705141E-F530-4657-BA2F-23F0F4A8BCB0}";
            ctx.RequestId               = "{59ACDBB4-3FAF-4056-9459-49D43C4128F9}";
            ctx.UserId                  = "kevin";
            ctx.UTCTransactionStartDate = DateTime.UtcNow;
            ctx.UTCTransactionStartTime = DateTime.UtcNow.ToString("HH:mm:ss.fff");
            header.HeaderInstance       = ctx;
            ws.SoapHeaders.Add(header);

            // Validation....
            var validation       = new XmlValidationStep();
            var schemaResultType = new SchemaDefinition
            {
                XmlSchemaPath =
                    @"C:\Affinus\Depot\ASS\Main\Dev\Src\VAA.ASS.Schemas\VAACommon\Result_Type.xsd",
                XmlSchemaNameSpace =
                    "http://schemas.virgin-atlantic.com/Common/2009"
            };

            validation.XmlSchemas.Add(schemaResultType);
            var schema = new SchemaDefinition
            {
                XmlSchemaPath =
                    @"C:\Affinus\Depot\ASS\Main\Dev\Src\VAA.ASS.Schemas\Book\GetProductTermsAndConditions_RS.xsd",
                XmlSchemaNameSpace =
                    "http://schemas.virgin-atlantic.com/AncillarySales/Book/Services/GetProductTermsAndConditions/2009"
            };

            validation.XmlSchemas.Add(schema);

            var xpathProductId = new XPathDefinition();

            xpathProductId.XPath = "/*[local-name()='GetProductTermsAndConditions_RS' and namespace-uri()='http://schemas.virgin-atlantic.com/AncillarySales/Book/Services/GetProductTermsAndConditions/2009']/*[local-name()='Message' and namespace-uri()='']/*[local-name()='TermsAndConditions' and namespace-uri()='']/@*[local-name()='productId' and namespace-uri()='']";
            xpathProductId.Value = "1";
            validation.XPathValidations.Add(xpathProductId);

            var xpathContent = new XPathDefinition();

            xpathContent.XPath = "/*[local-name()='GetProductTermsAndConditions_RS' and namespace-uri()='http://schemas.virgin-atlantic.com/AncillarySales/Book/Services/GetProductTermsAndConditions/2009']/*[local-name()='Message' and namespace-uri()='']/*[local-name()='TermsAndConditions' and namespace-uri()='']/*[local-name()='Content' and namespace-uri()='']";
            xpathContent.Value = "Terms and Conditions: this product is non-refundable....";
            validation.XPathValidations.Add(xpathContent);

            ws.SubSteps.Add(validation);
            btc.ExecutionSteps.Add(ws);

            BizUnit bu = new BizUnit(btc);

            TestCase.SaveToFile(btc, "WebServiceInvoke.xaml");
            bu.RunTest();
        }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the SoapEnvelope class.
 /// </summary>
 /// <param name="body">The body of the soap message</param>
 public SoapEnvelope(SoapBody body)
 {
     this.header = new WsdHeader();
     this.body   = body;
 }
Esempio n. 15
0
 public bool Contains(SoapHeader header)
 {
 }
Esempio n. 16
0
        /// < summary>
        /// 动态调用web服务
        /// < /summary>
        /// < param name="url">WSDL服务地址< /param>
        /// < param name="classname">类名< /param>
        /// < param name="methodname">方法名< /param>
        /// < param name="args">参数< /param>
        /// < returns>< /returns>
        public static object InvokeWebService(string url, string classname, string methodname, SoapHeader soapHeader, object[] args)
        {
            if (url.EndsWith("?wsdl", true, null))
            {
                url = url.Substring(0, url.Length - 5);
            }

            string @namespace = "EnterpriseServerBase.WebService.DynamicWebCalling";

            if ((classname == null) || (classname == ""))
            {
                classname = WebServicesUtil.GetWsClassName(url);
            }
            try
            {
                //获取WSDL
                WebClient                  wc     = new WebClient();
                Stream                     stream = wc.OpenRead(url + "?WSDL");
                ServiceDescription         sd     = ServiceDescription.Read(stream);
                ServiceDescriptionImporter sdi    = new ServiceDescriptionImporter();
                sdi.AddServiceDescription(sd, "", "");
                CodeNamespace cn = new CodeNamespace(@namespace);

                //生成客户端代理类代码
                CodeCompileUnit ccu = new CodeCompileUnit();
                ccu.Namespaces.Add(cn);
                sdi.Import(cn, ccu);
                CSharpCodeProvider icc = new CSharpCodeProvider();

                //设定编译参数
                CompilerParameters cplist = new CompilerParameters();
                cplist.GenerateExecutable = false;
                cplist.GenerateInMemory   = true;
                cplist.ReferencedAssemblies.Add("System.dll");
                cplist.ReferencedAssemblies.Add("System.XML.dll");
                cplist.ReferencedAssemblies.Add("System.Web.Services.dll");
                cplist.ReferencedAssemblies.Add("System.Data.dll");

                //编译代理类
                CompilerResults cr = icc.CompileAssemblyFromDom(cplist, ccu);
                if (cr.Errors.HasErrors)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (CompilerError ce in cr.Errors)
                    {
                        sb.Append(ce.ToString());
                        sb.Append(Environment.NewLine);
                    }
                    throw new Exception(sb.ToString());
                }

                //保存生产的代理类,默认是保存在bin目录下面
                TextWriter writer = File.CreateText("PdeWebServices.cs");
                icc.GenerateCodeFromCompileUnit(ccu, writer, null);
                writer.Flush();
                writer.Close();

                //生成代理实例
                Assembly assembly = cr.CompiledAssembly;
                Type     t        = assembly.GetType(@namespace + "." + classname, true, true);
                object   obj      = Activator.CreateInstance(t);

                #region 设置SoapHeader
                FieldInfo client    = null;
                object    clientkey = null;
                if (soapHeader != null)
                {
                    client = t.GetField(soapHeader.ClassName + "Value");
                    //获取客户端验证对象    soap类
                    Type typeClient = assembly.GetType(@namespace + "." + soapHeader.ClassName);
                    //为验证对象赋值  soap实例
                    clientkey = Activator.CreateInstance(typeClient);
                    //遍历属性
                    foreach (KeyValuePair <string, object> property in soapHeader.Properties)
                    {
                        typeClient.GetField(property.Key).SetValue(clientkey, property.Value);
                        // typeClient.GetProperty(property.Key).SetValue(clientkey, property.Value, null);
                    }
                }
                #endregion

                if (soapHeader != null)
                {
                    //设置Soap头
                    client.SetValue(obj, clientkey);
                    //pro.SetValue(obj, soapHeader, null);
                }

                //调用指定的方法
                MethodInfo mi = t.GetMethod(methodname);
                //方法名错误(找不到方法),给出提示
                if (null == mi)
                {
                    return("方法名不存在,请检查方法名是否正确!");
                }
                return(mi.Invoke(obj, args));
                // PropertyInfo propertyInfo = type.GetProperty(propertyname);
                //return propertyInfo.GetValue(obj, null);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException.Message, new Exception(ex.InnerException.StackTrace));
            }
        }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of the SoapEnvelope class.
 /// </summary>
 /// <param name="messageVersion">The version of the soap message</param>
 /// <param name="header">The header of the soap message</param>
 /// <param name="body">The body of the soap message</param>
 public SoapEnvelope(SoapMessageVersion messageVersion, SoapHeader header, SoapBody body)
 {
     this.messageVersion = messageVersion;
     this.header         = header;
     this.body           = body;
 }
Esempio n. 18
0
 /// <summary>
 /// 动态调用web服务(含有SoapHeader)
 /// </summary>
 /// <param name="url"></param>
 /// <param name="methodname"></param>
 /// <param name="soapHeader"></param>
 /// <param name="args"></param>
 /// <returns></returns>
 public static object InvokeWebService(string url, string methodname, SoapHeader soapHeader, object[] args)
 {
     return(WebServicesUtil.InvokeWebService(url, null, methodname, soapHeader, args));
 }
Esempio n. 19
0
        /// <summary>
        /// 调用WebService
        /// </summary>
        /// <param name="wsUrl">WebService地址</param>
        /// <param name="className">类名</param>
        /// <param name="methodName">方法名称</param>
        /// <param name="soapHeader">SOAP头</param>
        /// <param name="args">参数列表</param>
        /// <returns>返回调用结果</returns>
        public static object InvokeWebService(string wsUrl, string className, string methodName, SoapHeader soapHeader, object[] args)
        {
            string @namespace = "EnterpriseServerBase.WebService.DynamicWebCalling";

            if ((className == null) || (className == ""))
            {
                className = GetWsClassName(wsUrl);
            }
            try
            {
                //获取WSDL
                WebClient                  wc     = new WebClient();
                Stream                     stream = wc.OpenRead(wsUrl + "?wsdl");
                ServiceDescription         sd     = ServiceDescription.Read(stream);
                ServiceDescriptionImporter sdi    = new ServiceDescriptionImporter();
                sdi.AddServiceDescription(sd, "", "");
                CodeNamespace cn = new CodeNamespace(@namespace);

                //生成客户端代理类代码
                CodeCompileUnit ccu = new CodeCompileUnit();
                ccu.Namespaces.Add(cn);
                sdi.Import(cn, ccu);
                CSharpCodeProvider csc = new CSharpCodeProvider();
                ICodeCompiler      icc = csc.CreateCompiler();

                //设定编译参数
                CompilerParameters cplist = new CompilerParameters();
                cplist.GenerateExecutable = false;
                cplist.GenerateInMemory   = true;
                cplist.ReferencedAssemblies.Add("System.dll");
                cplist.ReferencedAssemblies.Add("System.XML.dll");
                cplist.ReferencedAssemblies.Add("System.Web.Services.dll");
                cplist.ReferencedAssemblies.Add("System.Data.dll");

                //编译代理类
                CompilerResults cr = icc.CompileAssemblyFromDom(cplist, ccu);
                if (true == cr.Errors.HasErrors)
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    foreach (System.CodeDom.Compiler.CompilerError ce in cr.Errors)
                    {
                        sb.Append(ce.ToString());
                        sb.Append(System.Environment.NewLine);
                    }
                    throw new Exception(sb.ToString());
                }


                //生成代理实例,并调用方法
                System.Reflection.Assembly assembly = cr.CompiledAssembly;
                Type t = assembly.GetType(@namespace + "." + className, true, true);

                FieldInfo[] arry = t.GetFields();

                FieldInfo client    = null;
                object    clientkey = null;
                if (soapHeader != null)
                {
                    //Soap头开始
                    client = t.GetField(soapHeader.ClassName + "Value");

                    //获取客户端验证对象
                    Type typeClient = assembly.GetType(@namespace + "." + soapHeader.ClassName);

                    //为验证对象赋值
                    clientkey = Activator.CreateInstance(typeClient);

                    foreach (KeyValuePair <string, object> property in soapHeader.Properties)
                    {
                        typeClient.GetField(property.Key).SetValue(clientkey, property.Value);
                    }
                    //Soap头结束
                }

                //实例类型对象
                object obj = Activator.CreateInstance(t);

                if (soapHeader != null)
                {
                    //设置Soap头
                    client.SetValue(obj, clientkey);
                }

                System.Reflection.MethodInfo mi = t.GetMethod(methodName);

                return(mi.Invoke(obj, args));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException.Message, new Exception(ex.InnerException.StackTrace));
            }
        }
Esempio n. 20
0
 /// <summary>
 /// 调用WebService(带SoapHeader)
 /// </summary>
 /// <param name="wsUrl">WebService地址</param>
 /// <param name="methodName">方法名称</param>
 /// <param name="soapHeader">SOAP头</param>
 /// <param name="args">参数列表</param>
 /// <returns>返回调用结果</returns>
 public static object InvokeWebService(string wsUrl, string methodName, SoapHeader soapHeader, object[] args)
 {
     return(InvokeWebService(wsUrl, null, methodName, soapHeader, args));
 }
Esempio n. 21
0
 public void Insert(int index, SoapHeader header)
 {
 }
Esempio n. 22
0
 // Methods
 public int Add(SoapHeader header)
 {
 }
Esempio n. 23
0
 public int IndexOf(SoapHeader header)
 {
 }
 /// <summary>
 /// Initializes a new instance of the SoapEnvelope class.
 /// </summary>
 /// <param name="body">The body of the soap message</param>
 public SoapEnvelope(SoapBody body)
 {
     this.header = new WsdHeader();
     this.body = body;
 }
Esempio n. 25
0
 public void Remove(SoapHeader header)
 {
 }
Esempio n. 26
0
 /// <summary>   
 /// 调用WebService(带SoapHeader)
 /// </summary>   
 /// <param name="wsUrl">WebService地址</param>   
 /// <param name="methodName">方法名称</param>   
 /// <param name="soapHeader">SOAP头</param>   
 /// <param name="args">参数列表</param>   
 /// <returns>返回调用结果</returns>
 public static object InvokeWebService(string wsUrl, string methodName, SoapHeader soapHeader, object[] args)
 {
     return InvokeWebService(wsUrl, null, methodName, soapHeader, args);
 }
 /// <summary>
 /// Initializes a new instance of the SoapEnvelope class.
 /// </summary>
 /// <param name="messageVersion">The version of the soap message</param>
 /// <param name="header">The header of the soap message</param>
 /// <param name="body">The body of the soap message</param>
 public SoapEnvelope(SoapMessageVersion messageVersion, SoapHeader header, SoapBody body)
 {
     this.messageVersion = messageVersion;
     this.header = header;
     this.body = body;
 }
 // Methods
 public int Add(SoapHeader header)
 {
 }
 public SoapEnvelope(SoapHeader header, SoapBody body)
 {
     Header = header;
     Body   = body;
 }
 public bool Contains(SoapHeader header)
 {
 }