/[dgee]/dgee/tools/csws2client.cs
ViewVC logotype

Diff of /dgee/tools/csws2client.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by csmith, Sun Sep 21 10:30:15 2003 UTC revision 1.5 by csmith, Tue Oct 28 00:33:03 2003 UTC
# Line 69  public class CSWS2Client Line 69  public class CSWS2Client
69    private String xmlrpcUrl;    private String xmlrpcUrl;
70    private String classname;    private String classname;
71    private String inputFile;    private String inputFile;
72      private String wsname;
73    
74    internal static String IndentStr = "";    internal static String IndentStr = "";
75    private const char indentChar    = ' ';      private const char indentChar    = ' ';  
# Line 199  public class CSWS2Client Line 200  public class CSWS2Client
200      if( attr != null ) {      if( attr != null ) {
201        desc = ((WebServiceAttribute)attr).Description;        desc = ((WebServiceAttribute)attr).Description;
202        ns   = ((WebServiceAttribute)attr).Namespace;        ns   = ((WebServiceAttribute)attr).Namespace;
         
       if( ns == null ) {  
         ns = "http://tempuri.org";  
       };  
203      }      }
204          
205        if( ns == null ) {
206              ns = "http://tempuri.org";
207        };
208              
209                                    
210      if( opt.Verbose ) {      if( opt.Verbose ) {
211        Console.Write( "Processing {0}: ", type.ToString() );        Console.Write( "Processing {0}: ", type.ToString() );
# Line 216  public class CSWS2Client Line 218  public class CSWS2Client
218      writer.WriteLine( "{0}//", IndentStr );      writer.WriteLine( "{0}//", IndentStr );
219      writer.WriteLine( "{0}// Class {1}", IndentStr, classname );      writer.WriteLine( "{0}// Class {1}", IndentStr, classname );
220      writer.WriteLine( "{0}//", IndentStr );      writer.WriteLine( "{0}//", IndentStr );
221      writer.WriteLine( "{0}[XmlRpcUrl(\"{1}\")]", IndentStr, xmlrpcUrl );      writer.WriteLine( "{0}public class {1} : XmlRpcClientProtocol", IndentStr, classname );
     writer.WriteLine( "{0}public class {1}", IndentStr, classname );  
222      writer.WriteLine( "{0}{{ ", IndentStr );      writer.WriteLine( "{0}{{ ", IndentStr );
223    
224      IndentStatement();      IndentStatement();
225      writer.WriteLine( "{0}private XmlRpcClientProtocol xmlclient;", IndentStr );      writer.WriteLine( "{0}public {1}() {{", IndentStr, classname );
226        IndentStatement();
227        writer.WriteLine( "{0}this.Url = \"{1}\";", IndentStr, xmlrpcUrl );
228        UnIndentStatement();
229        writer.WriteLine( "{0}}}", IndentStr );
230    
231      // Retrieve the methods for this class via reflection and process      // Retrieve the methods for this class via reflection and process
232      // them iteratively      // them iteratively
233      MethodInfo []methods =      MethodInfo []methods =
234        type.GetMethods( BindingFlags.Public | BindingFlags.Static);        type.GetMethods(); // BindingFlags.Public | BindingFlags.Static);
235            
236      foreach( MethodInfo method in methods ) {      foreach( MethodInfo method in methods ) {
237        // Process the parameter list for the method        // Process the parameter list for the method
# Line 251  public class CSWS2Client Line 256  public class CSWS2Client
256      }      }
257            
258      //serviceName = GetServiceAttribute(method).ToString();          //serviceName = GetServiceAttribute(method).ToString();    
259        String methName = ((WebMethodAttribute)attr).Method;
260            if( methName == null ) {
261              methName = method.Name;
262            }
263    
264      writer.WriteLine();      writer.WriteLine();
265      writer.WriteLine( "{0}[XmlRpcMethod(\"{1}\")]", IndentStr, method.Name);      writer.Write( "{0}public {1} {2}", IndentStr, method.ReturnType, methName);
     writer.Write( "{0}public {1} {2}", IndentStr, method.ReturnType, method.Name);  
266                            
267      ParameterInfo []pinfos = method.GetParameters();      ParameterInfo []pinfos = method.GetParameters();
268      String parameters      = String.Empty;      String parameters      = String.Empty;
# Line 272  public class CSWS2Client Line 280  public class CSWS2Client
280      writer.WriteLine( "{0}{{", IndentStr );      writer.WriteLine( "{0}{{", IndentStr );
281                                    
282      IndentStatement();      IndentStatement();
283      writer.WriteLine( "{0}xmlclient = new XmlRpcClientProtocol( typeof( {1} ) );", IndentStr, classname );      writer.WriteLine( "{0}object[] results = this.Invoke( \"{1}\", new object[] {{ {2} }} );", IndentStr, methName, argsObj );
284      writer.WriteLine( "{0}XmlRpcRequest reqStream = new XmlRpcRequest();", IndentStr );  
285      writer.WriteLine( "{0}reqStream.Method = \"{1}\";", IndentStr, method.Name );      writer.WriteLine( "{0}return (({1})(results[0]));", IndentStr, method.ReturnType );
     writer.WriteLine( "{0}reqStream.Arguments = new Object[] {{{1}}};", IndentStr, argsObj );  
     writer.WriteLine( "{0}XmlRpcResponse resp = xmlclient.Invoke( reqStream );", IndentStr );  
     writer.WriteLine( "{0}return ({1})resp.retVal;", IndentStr, method.ReturnType );  
286    
287      UnIndentStatement();      UnIndentStatement();
288      writer.WriteLine( "{0}}}", IndentStr );      writer.WriteLine( "{0}}}", IndentStr );
# Line 290  public class CSWS2Client Line 295  public class CSWS2Client
295      int done = 0;      int done = 0;
296      dllName  = Path.GetFullPath( dllName );      dllName  = Path.GetFullPath( dllName );
297      String prefix = Path.GetFileNameWithoutExtension( dllName );      String prefix = Path.GetFileNameWithoutExtension( dllName );
298      //webName = prefix + ".dgmx";      webName = prefix + ".dgmx";
299      FileStream fs = new FileStream( prefix + "Client.cs", FileMode.Create );      FileStream fs = new FileStream( prefix + "Client.cs", FileMode.Create );
300                                    
301      writer = new StreamWriter( fs, Encoding.ASCII );      writer = new StreamWriter( fs, Encoding.ASCII );
# Line 303  public class CSWS2Client Line 308  public class CSWS2Client
308      WriteCopyright();      WriteCopyright();
309      WriteIncludes();      WriteIncludes();
310    
311      writer.WriteLine ( "namespace DGMXClient\n{" );      writer.WriteLine ( "namespace " + prefix + "\n{" );
312      IndentStatement();      IndentStatement();
313            
314      // Load the aseembly from its dll and get the type info via      // Load the aseembly from its dll and get the type info via
# Line 394  public class CSWS2Client Line 399  public class CSWS2Client
399          break;          break;
400                
401        default:        default:
402          if( arg.EndsWith( ".dll" ) ) {              inputFile = arg;
           inputFile = arg;  
         }  
         else {  
           Console.WriteLine( "{0}: Invalid argument or file name", arg);  
         }  
403          break;          break;
404        }        }
405      }      }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26