Return WsdlFromFile (Source);
// Try to get from the file system
}
Public string wsdlfromfile (String FileFullPathname)
{
FileInfo Fi = New FileInfo (FileFullPathname);
IF (FI.EXTension == "WSDL")
{
FILESTREAM FS = New FileStream (FileFullPathname, FileMode.Open,
FileAccess.read;
StreamReader SR = New StreamReader (FS);
Char [] buffer = new char [(int) fs.length];
Sr.Readblock (buffer, 0, (int) fs.length);
Return New String (Buffer);
}
Throw New Exception ("this is no a wsdl file");
}
// Make Assembly for Specified WSDL Text
Public assembly assemblyFromWSDL (String strwsdl)
{
// XML Text Reader
StringReader WSDLStringReader = New StringReader (STRWSDL);
XMLTextReader Tr = New XMLTextReader (WSDLStringReader);
Servicedescription SD = ServicesDescription.read (TR);
Tr.Close ();
// WSDL Service Description Importer
CODENAMESPACE CNS = New CodenameSpace ("rkiss.webserviceAccessor");
ServiceDescriptionImporter SDI = New ServicesDescriptionImp Porter ();
SDi.AddServicedScription (SD, NULL, NULL);
SDI.PROTOCOLNAME = _Protocolname;
SDI.IMPORT (CNS, NULL);
// Source Code Generation
CsharpcodeProvider Cscp = New CsharpcodeProvider ();
ICodeGenerator ICG = cscp.creategenerator ();
Stringbuilder srcstringbuilder = new stringbuilder ();
StringWriter SW = New StringWriter (srcstringbuilder);
Icg.generatecodefromNamespace (CNS, SW, NULL);
_srcwsproxy = srcstringbuilder.tostring ();
SW.CLOSE ();
// assembly compilation.
CompilerParameters cp = new compilerparameters ();
cp.referencedassemblies.add ("system.dll");
cp.referencedassemblies.add ("System.xml.dll");
Cp.ReferenceDassemblies.add ("System.web.services.dll"); cp.generateexecutable = false;
Cp.GenerateInmemory = True;
Cp.includebuginformation = false;
ICodeCompiler ICC = cscp.createcompiler ();
CompilerResults cr = icc.compileAssemblyfromsource (CP, _SRCWSPROXY);
IF (cr.errors.count> 0)
Throw new Exception (String.Format ("Build Failed: {0} ErrorS",
Cr.Errors.count);
Return_Ass = cr.compiledassembly;
}
// CREATE Instance of the Web Service Proxy
Public Object CreateInstance (String ObjTypename)
{
TYPE T = _Ass.gettype ("RKISS.WEBSERVICEACCESSOR" "." ObjTypename);
Return Activator.createInstance (T);
}
// Invoke Method on The Obj
Public Object Invoke (Object Obj, String MethodName, Params Object [] ARGS
{
MethodInfo Mi = Obj.gettype (). GetMethod (MethodName);
Return Mi.invoke (OBJ, ARGS);
}
}
WebserviceEventargs class.
The WebServiceEventArgs class is used to pass the call status. This has an example of helping you understand the concept. This class is dependent on this application, but only one field is defined as _state. This field is a Callback
Cookie; additionally, there are two ways to serialize / deserialize. Here I use explicitly and implicit operators to operate / incoming strings.
// The Callback State Class
[Serializable]
Public Class WebServiceEventArgs: Eventargs
{
Private string _name;
Private string_state;
Private int _paham;
//
Public String Name
{
Get {return _name;}
Set {_name = value;}
}
Public String State
{
Get {return _state;}
Set {_State = Value;}
}
Public Int Param
{
Get {return_param;}
Set {_Param = Value;}
}
Public Static Implicit Operator String (WebServiceEventArgs Obj)
{
StringBuilder XmlstringBuilder = new stringbuilder ();
XmlTextWriter TW = New XmlTextWriter (New StringWriter (NEW STRINGWRITER
XMLStringBuilder);
XMLSerializer Serializer = New XMLSerializer (TypeOf (WebServiceEventArgs);
Serializer.Serialize (TW, OBJ);
Tw.close ();
Return XmlstringBuilder.toString ();
}
Public Static Explicit Operator WebServiceEventArgs (String XMlobj)
{
XMLSerializer Serializer = New XMLSERIALIZER (
TypeOf (WebServiceEventArgs);
XMLTextReader TR = New StringRextReader (New StringReader (XMLOBJ));
WebserviceEventArgs EA =
Serializer.deSerialize (TR) AS WebServiceEventArgs;
Tr.Close ();
Return EA;
}
}