Slow SoapHttpClientProtocol constructor

后端 未结 6 1790
情话喂你
情话喂你 2020-12-02 10:28

I\'m doing some experiments with Microsoft Dynamics CRM. You interact with it through web services and I have added a Web Reference to my project. The web service interface

6条回答
  •  旧时难觅i
    2020-12-02 11:10

    I have used above detailed answer as guide, and went a few steps forward, making a script to automate process. Script is made out of two files :

    generateproxy.bat :

    REM if your path for wsdl, csc or sgen is missing, please add it here (it varies from machine to machine)
    set PATH=%PATH%;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools;C:\Program Files (x86)\MSBuild\14.0\Bin
    
    wsdl http://localhost:57237/VIM_WS.asmx?wsdl REM create source code out of WSDL
    PowerShell.exe -ExecutionPolicy Bypass -Command "& '%~dpn0.ps1'" REM proces source code (remove annotations, add other annotation, put class into namespace)
    csc /t:library /out:references\VIM_Service.dll VIM_WS.cs REM compile source into dll
    sgen /p references\VIM_Service.dll /force REM generate serializtion dll
    

    generateproxy.ps1

    (Get-Content VIM.cs) | 
        ForEach-Object { 
            $_ -replace "(?\[global::System.Xml.Serialization.[^\]]*\])", "/*${attr}*/" `
                -replace "public partial class VIM", "[System.Xml.Serialization.XmlSerializerAssemblyAttribute(AssemblyName = ""VIM_Service.XmlSerializers"")] `npublic partial class VIM" `
                -replace "using System;", "namespace Classes.WS_VIM {   `n`nusing System;"
        } |
    Set-Content VIM.cs
    Add-Content VIM.cs "`n}"
    

    I have added those two files to client project, and in the pre-build event I have added lines

    cd..\..
    generateproxy
    

    So, before every build, proxy classes are regenerated, and developer has (almost) no need to think about it. While building, WS must be up and running, and its URL must be in bat file. As a result of prebuild, two dll files will regenerate in client project's subfolder references. After first execution of scripts, you should add reference to new dll.

提交回复
热议问题