/[dgee]/dgee/cslib/DotGNU.XmlRpc/XmlRpcClientProtocol.cs
ViewVC logotype

Diff of /dgee/cslib/DotGNU.XmlRpc/XmlRpcClientProtocol.cs

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

revision 1.5 by minddog, Sun Mar 30 16:15:28 2003 UTC revision 1.6 by minddog, Sun Aug 24 17:21:18 2003 UTC
# Line 37  namespace DotGNU.XmlRpc Line 37  namespace DotGNU.XmlRpc
37                  private XmlRpcServiceInfo clientInfo;                  private XmlRpcServiceInfo clientInfo;
38                  private XmlRpcSerializer ser;                  private XmlRpcSerializer ser;
39                  private XmlRpcDeserializer dser;                  private XmlRpcDeserializer dser;
40                                    private String header;
41                  public XmlRpcClientProtocol(IPHostEntry host) : base (host)                  public XmlRpcClientProtocol(IPHostEntry host) : base (host)
42                  {                  {
43    
# Line 45  namespace DotGNU.XmlRpc Line 45  namespace DotGNU.XmlRpc
45    
46                  public XmlRpcClientProtocol(MemberInfo type) : base(new IPHostEntry())                  public XmlRpcClientProtocol(MemberInfo type) : base(new IPHostEntry())
47                  {                  {
48                            String url = String.Empty;
49                            String port = String.Empty;    
50                            String dest = String.Empty;
51                          Object[] attributes = type.GetCustomAttributes(typeof(XmlRpcUrlAttribute), false);                          Object[] attributes = type.GetCustomAttributes(typeof(XmlRpcUrlAttribute), false);
52                          XmlRpcUrlAttribute xmlrpcUrl = (XmlRpcUrlAttribute)attributes[0];                          XmlRpcUrlAttribute xmlrpcUrl = (XmlRpcUrlAttribute)attributes[0];
53                          String tmpUrl = xmlrpcUrl.Uri;                          String tmpUrl = xmlrpcUrl.Uri;
54                          int spot = tmpUrl.LastIndexOf("://")+3;                          int spot = tmpUrl.LastIndexOf("://")+3;
55                          tmpUrl = tmpUrl.Substring(spot, tmpUrl.Length - spot);                          tmpUrl = tmpUrl.Substring(spot, tmpUrl.Length - spot);
56                          spot = tmpUrl.IndexOf("/");                          spot = tmpUrl.IndexOf("/");
57                            dest = tmpUrl.Substring(spot, tmpUrl.Length-spot);
58                          tmpUrl = tmpUrl.Substring(0, spot);                          tmpUrl = tmpUrl.Substring(0, spot);
59                          spot = tmpUrl.IndexOf(":");                          spot = tmpUrl.IndexOf(":");
60                          String url = tmpUrl.Substring(0, spot);                          if(spot != -1)
61                          String port = tmpUrl.Substring(spot+1, tmpUrl.Length -spot -1);                          {      
62                          Console.WriteLine(url + " port " + port);                                  // find port
63                                    url = tmpUrl.Substring(0, spot);
64                                    port = tmpUrl.Substring(spot+1, tmpUrl.Length -spot -1);
65                            }
66                            else
67                            {
68                                    port = "80";
69                                    url = tmpUrl;
70                            }
71                            header = "POST " + dest + " HTTP/1.0\nContent-Type: text/xml\nContent-Length: ";        
72                          info = Dns.Resolve(url);                          info = Dns.Resolve(url);
73                  }                  }
74    
# Line 63  namespace DotGNU.XmlRpc Line 76  namespace DotGNU.XmlRpc
76                  {                  {
77                                                    
78                          ser = new XmlRpcSerializer();                          ser = new XmlRpcSerializer();
79                          int state = Send( ser.SerializeRequest( request ).ToString() );                          String requestXml = ser.SerializeRequest( request ).ToString();
80                            int state = Send( requestXml );
81                          if(state != -1)                          if(state != -1)
82                          {                          {
83                                  XmlRpcResponse response = new XmlRpcResponse(receivedASCII);                                  XmlRpcResponse response = new XmlRpcResponse(receivedASCII);
# Line 81  namespace DotGNU.XmlRpc Line 95  namespace DotGNU.XmlRpc
95                          return true;                          return true;
96                  }                  }
97    
98                  public override int Send(String data)                  public int Send(String data)
99                  {                  {
100                                  if(data == null)                                  if(data == null)
101                                  {                                  {
# Line 96  namespace DotGNU.XmlRpc Line 110  namespace DotGNU.XmlRpc
110                                  IPAddress[] ipaddress = info.AddressList;                                  IPAddress[] ipaddress = info.AddressList;
111                                  EndPoint ep = new IPEndPoint(ipaddress[0], 80);                                  EndPoint ep = new IPEndPoint(ipaddress[0], 80);
112                                  sock.Connect(ep);                                  sock.Connect(ep);
113                                    data = header + data.Length + "\n\n" + data;
114                                  if(sock.Connected)                                  if(sock.Connected)
115                                  {                                  {
116                                          sock.Send(ASCII.GetBytes(data), ASCII.GetBytes(data).Length, 0);                                          sock.Send(ASCII.GetBytes(data), ASCII.GetBytes(data).Length, 0);

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

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