Dynamic calling WebService

xiaoxiao2021-03-06  80

///

/ / / / / / / param> ////////////// / / / / / /// Webservice address /// < Param name = "namespace"> WebService's namespace ">" ClassName ">" ClassName ">" ClassName ">" ClassName ">" ClassName ">" Does not include a namespace prefix) ////// WebService's method name /// Parameter list /// Webservice execution result /// /// If the call fails, an Exception will be thrown. Please call the exception when calling. /// Abnormal information may happen to two places: /// 1, when dynamically constructed WebService, CompileAsessembly failed. /// 2, the WebService itself failed.

/// /// /// /// Object obj = invokeebservice ("http://localhost/gsp_workflowwebservice/common.asmx", "menersoft.platform.service.workflow" , "Common", "GetToolType", new object [] {"1"}); /// /// /// Private Object InvokeWebService (String Url, String @Namespace, String Classname, String MethodName , object [] args) {try {system.net.WebClient wc = new system.net.WebClient (); system.io.stream stream = wc.Openread (URL "? WSDL"); System.Web.Services.Description .ServiceDescription sd = System.Web.Services.Description.ServiceDescription.Read (stream); System.Web.Services.Description.ServiceDescriptionImporter sdi = new System.Web.Services.Description.ServiceDescriptionImporter (); sdi.AddServiceDescription (sd, " "," "); System.CodeDom.CodeNamespace cn = new System.CodeDom.CodeNamespace (@namespace); System.CodeDom.CodeCompileUnit ccu = new System.CodeDom.CodeCompileUnit (); ccu.Namespaces.Add (cn); sdi .Import (CN, CCU); MI Crosoft.csharp.csharpcodeProvider CSC = New Microsoft.csharp.csharpcodeProvider (); system.codedom.compiler.icodeCompiler ICC = csc.createcompiler ();

System.CodeDom.Compiler.CompilerParameters cplist = new System.CodeDom.Compiler.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");

转载请注明原文地址:https://www.9cbs.com/read-120801.html

New Post(0)