achieve
The key to the design is that there is a virtual agent that can access any Web Service, which is based on WSDL. WebServiceAccessor can handle this task. I use a separate assembly to implement it, and this is also easy to add it to the .NET project. Similarly, it is also necessary for the Callback method WebServiceEventArgs class.
Virtual Web Service Agent
Designing virtual service agents The desire to generate a specific web service in the memory REFLECTION process.
If a landing parameter can be used to describe a direct web servicedl or obtain its indirect information from its description. The file system and URL address can be indirectly implemented. All processes are divided into three pieces as shown in the following images:
The source code code of the Web Service is only stored in the class for test purposes. The result of this image and the WSDL.exe program is exactly the same. Some of my previous articles have already described these. With a proxy source, then compile it and generate it is easy. Once we have a proxy Assembly, we can initialize a proxy class and call its member method.
The following code snippets show its implementation:
// Virtual Web Service Accessor
Public Class WebServiceAccessor
{
PRIVATESEMBLY_ASS = NULL;
// askSEMBLY OF THE Web Service Proxy
Private string _Protocolname = "soap";
// Communication Protocol
Private string _srcwsproxy = string.empty;
// source text (.cs)
//
Public assembly assembly {get {return_ass;}}
Public String Protocolname
{get {return _protocolname;} set {_protocolname = value;}}
Public string srcwsproxy {get {return _srcwsproxy;}}
Public WebServiceAccessor ()
{
}
Public WebServiceAccessor (String WsdlsourceName)
{
AssemblyFromWSDL (getWsdl (WSDLSourceName);
}
// Get the WSDL Text from Specified Source
Public String WsdlFromurl (String URL)
{
WebRequest Req = WebRequest.create (URL);
WebResponse result = req.getResponse ();
Street.getReStream = Result.getResponseSstream ();
Encoding encode = system.text.encoding.getencoding ("UTF-8");
StreamReader SR = New StreAMReader (ReceiveStream, Encode);
String strwsdl = sr.readtoend ();
Return strwsdl;
}
Public String getWsdl (String Source)
{
IF (Source.StartSwith (" { Return Source; // this can be a wsdl string} Else IF (Source.StartSwith ("http: //") == true) { Return WSDLFromurl (Source); // this is a url address }