• 大小: 31.80M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2020-12-26
  • 语言: C#
  • 标签: webservice  service  web  IC  数据  

资源简介

客户端动态链接服务端,服务端按用户名,写入数据库不同数据表并生成打印数据返回客户端打印。
IIS新建网站,设置好IP地址,目录指向Report_WebService\Report_Service,
在“应用程序池”,点击该网站,点击“高级设置”,“启用32位应用程序”设置为True。
启动客户端(client),登录输入网址http://xxx.xx.xx.xx/,“/”要输入完整,
用户名1001或1002,密码123456,两个用户写入服务端不同数据表,并打印相应报表。
此例结合https://www.haolizi.net/example/view_37952.html使用参考。
只说明方法的示例,写的较为粗陋,仅供参考。

public class WebServiceHelper
    {
        public static string Separator = "[◢℡]"; // 分隔符
        public static Type WebService_Type;
        public static bool run_service = false;

        public static void Get_Service(string url)
        {
            WebClient web = new WebClient();
            Stream stream = web.OpenRead(url "Report.asmx?WSDL");
            ServiceDescription description = ServiceDescription.Read(stream);
            ServiceDescriptionImporter importer = new ServiceDescriptionImporter();

            importer.ProtocolName = "Soap";
            importer.Style = ServiceDescriptionImportStyle.Client;
            importer.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties | CodeGenerationOptions.GenerateNewAsync;
            importer.AddServiceDescription(description, null, null);
            CodeNamespace nmspace = new CodeNamespace();
            CodeCompileUnit unit = new CodeCompileUnit();
            unit.Namespaces.Add(nmspace);
            ServiceDescriptionImportWarnings warning = importer.Import(nmspace, unit);
            CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");
            CompilerParameters parameter = new CompilerParameters();
            parameter.GenerateExecutable = false;
            parameter.GenerateInMemory = true;
            CompilerResults result = provider.CompileAssemblyFromDom(parameter, unit);
            Assembly asm = result.CompiledAssembly;
            WebService_Type = asm.GetType("Report");

            run_service = true;
        }

        public static string Run_ServiceOption(string option, object[] array)
        {
            object o = Activator.CreateInstance(WebService_Type);
            MethodInfo method = WebService_Type.GetMethod(option);
            return method.Invoke(o, array).ToString();
        }
    }

资源截图

代码片段和文件信息

using System.Runtime.Serialization.Json;
using System.IO;
using System.xml.Serialization;
using System.xml;
using System.Runtime.Serialization.Formatters.Binary;

public class Client_Serializer
{
    /// 将对象序列化为json文件
    public static void objectToJson(T t string path) where T : class
    {
        DataContractJsonSerializer formatter = new DataContractJsonSerializer(typeof(T));
        using (FileStream stream = new FileStream(path FileMode.OpenOrCreate))
        {
            formatter.Writeobject(stream t);
        }
    }

    /// 将对象序列化为json字符串
    public static string objectToJson(T t) where T : class
    {
        DataContractJsonSerializer formatter = new DataContractJsonSerializer(typeof(T));
        using (MemoryStream stream = new MemoryStream())

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     61952  2020-02-09 00:11  Client\.vs\Client\v16\.suo

     文件          0  2020-02-08 09:39  Client\.vs\Client\v16\Server\sqlite3\db.lock

     文件     663552  2020-02-09 00:11  Client\.vs\Client\v16\Server\sqlite3\storage.ide

     文件        189  2020-02-08 09:39  Client\Client\App.config

     文件      24064  2020-02-09 00:04  Client\Client\bin\Debug\Client.exe

     文件        189  2020-02-08 09:39  Client\Client\bin\Debug\Client.exe.config

     文件      56832  2020-02-09 00:04  Client\Client\bin\Debug\Client.pdb

     文件     243712  2019-12-27 21:33  Client\Client\bin\Debug\contextUI.dll

     文件     419328  2020-02-04 10:06  Client\Client\bin\Debug\RptBuild.dll

     文件     256000  2020-01-09 12:44  Client\Client\bin\Debug\websocket-sharp.dll

     文件       4771  2020-02-08 21:52  Client\Client\Client.csproj

     文件       4550  2020-02-08 21:52  Client\Client\Client_Serializer.cs

     文件       5311  2020-02-09 00:03  Client\Client\Form1.cs

     文件      25987  2020-02-08 22:55  Client\Client\Form1.Designer.cs

     文件       5817  2020-02-08 22:55  Client\Client\Form1.resx

     文件       1343  2020-02-08 22:00  Client\Client\login.cs

     文件       7110  2020-02-08 21:59  Client\Client\login.Designer.cs

     文件       5817  2020-02-08 21:59  Client\Client\login.resx

     文件          0  2020-02-09 00:04  Client\Client\obj\Debug\Client.csproj.CopyComplete

     文件        580  2020-02-08 23:56  Client\Client\obj\Debug\Client.csproj.FileListAbsolute.txt

     文件       1070  2020-02-08 23:56  Client\Client\obj\Debug\Client.csproj.GenerateResource.cache

     文件      24064  2020-02-09 00:04  Client\Client\obj\Debug\Client.exe

     文件        180  2020-02-08 23:56  Client\Client\obj\Debug\Client.Form1.resources

     文件        180  2020-02-08 23:56  Client\Client\obj\Debug\Client.login.resources

     文件      56832  2020-02-09 00:04  Client\Client\obj\Debug\Client.pdb

     文件        180  2020-02-08 23:56  Client\Client\obj\Debug\Client.Properties.Resources.resources

     文件       1435  2020-02-08 14:10  Client\Client\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7507  2020-02-08 21:51  Client\Client\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        683  2020-02-08 10:22  Client\Client\Program.cs

     文件       1304  2020-02-08 09:39  Client\Client\Properties\AssemblyInfo.cs

............此处省略251个文件信息

评论

共有 条评论