using System;
using System.Runtime.Remoting;
using System.Xml.Serialization;
using System.Web.Services;
namespace NSConfig {
public class ClientService : NSConfigService
{
private static string cookie = null;
/* override the getWebRequest to send cookie */
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
System.Net.HttpWebRequest req = (System.Net.HttpWebRequest) base.GetWebRequest(uri);
if (cookie != null)
{
req.Headers.Add("Set-Cookie", cookie);
}
return req;
}
/* override the getWebResponse to get the cookie */
protected override System.Net.WebResponse GetWebResponse(System.Net.WebRequest req)
{
System.Net.HttpWebResponse rep = (System.Net.HttpWebResponse) base.GetWebResponse(req);
if (rep.Headers["Set-Cookie"] != null)
{
cookie = rep.Headers["Set-Cookie"];
}
return rep;
}
public ClientService()
{
this.Url = "http:;
}
public ClientService(string servername)
{
this.Url = "http:+servername+"/soap";;
}
}
class tcp_buffering
{
static ClientService client=null;
[STAThread]
static void Main(string[] args)
{
if ( args.Length < 3)
{
Console.WriteLine("Usage: getConfig <NS IP> username password");
return;
}
string serverip = args[0];
string username = args[1];
string password = args[2];
try {
Console.WriteLine("\nConnecting to server "+serverip+" ............\n");
client = new ClientService(serverip);
client.CookieContainer = new System.Net.CookieContainer();
simpleResult result = client.login(username,password) ;
Console.WriteLine("login : "+result.message);
result = client.enablensmode(modeEnum.TCPB);
Console.WriteLine("enablensmode TCPB : " + result.message);
result = client.setnstcpbufparam_size(64);
Console.WriteLine("setnstcpbufparam_size 64 : " + result.message);
result = client.setnstcpbufparam_memlimit(100);
Console.WriteLine("setnstcpbufparam_memlimit 100 : " + result.message);
getnstcpbufparamResult getnstcpbufparamresult1 = client.getnstcpbufparam();
Console.WriteLine("getnstcpbufparam 100 : " + getnstcpbufparamresult1.message);
if ( (getnstcpbufparamresult1.List != null) && (getnstcpbufparamresult1.List.Length > 0)) {
for(int i =0 ; i < getnstcpbufparamresult1.List.Length;i++) {
nstcpbufparam obj;
obj = (nstcpbufparam) getnstcpbufparamresult1.List[i];
Console.WriteLine( obj.size + "\t" + obj.memlimit + "\t" );
}
}
result = client.addserver("s1","10.102.3.84",null,enabledisabledEnum.VALNOTSET);
Console.WriteLine("addserver s1 : " + result.message);
getserverResult getserverresult2 = client.getserver("s1",false);
Console.WriteLine("getserver s1 : " + getserverresult2.message);
if ( (getserverresult2.List != null) && (getserverresult2.List.Length > 0)) {
for(int i =0 ; i < getserverresult2.List.Length;i++) {
server obj;
obj = (server) getserverresult2.List[i];
Console.WriteLine( obj.name + "\t" + obj.internaL + "\t" + obj.ipaddress + "\t" + obj.state + "\t" + obj.domain + "\t" + obj.domainresolveretry + "\t" + obj.servicename + "\t" + obj.servicegroupname + "\t" );
}
}
result = client.addservice("svc1",null,"s1",servicetypeEnum.HTTP,80,0xFFFFFFFF,cachtypeEnum.VALNOTSET,enabledisabledEnum.VALNOTSET);
Console.WriteLine("addservice svc1 : " + result.message);
getserviceResult getserviceresult3 = client.getservice("svc1",false,false);
Console.WriteLine("getservice svc1 : " + getserviceresult3.message);
if ( (getserviceresult3.List != null) && (getserviceresult3.List.Length > 0)) {
for(int i =0 ; i < getserviceresult3.List.Length;i++) {
service obj;
obj = (service) getserviceresult3.List[i];
Console.WriteLine( obj.name + "\t" + obj.all + "\t" + obj.internaL + "\t" + obj.servername + "\t" + obj.servicetype + "\t" + obj.serviceconftpye + "\t" + obj.port + "\t" + obj.value + "\t" + obj.cleartextport + "\t" + obj.gslb + "\t" + obj.cachetype + "\t" + obj.maxclient + "\t" + obj.maxreq + "\t" + obj.cacheable + "\t" + obj.cip + "\t" + obj.cipheader + "\t" + obj.usip + "\t" + obj.sc + "\t" + obj.weight + "\t" + obj.sp + "\t" + obj.failedprobes + "\t" + obj.clttimeout + "\t" + obj.totalprobes + "\t" + obj.svrtimeout + "\t" + obj.totalfailedprobes + "\t" + obj.serverid + "\t" + obj.cka + "\t" + obj.tcpb + "\t" + obj.cmp + "\t" + obj.maxbandwidth + "\t" + obj.accessdown + "\t" + obj.svrstate + "\t" + obj.ipaddress + "\t" + obj.monitorname + "\t" + obj.monthreshold + "\t" + obj.monstate + "\t" + obj.monstatcode + "\t" + obj.responsetime + "\t" + obj.downstateflush + "\t" + obj.statechangetimesec + "\t" + obj.statechangetimemsec + "\t" + obj.timesincelaststatechange + "\t" + obj.tickssincelaststatechange + "\t" + obj.scpolicyname + "\t" + obj.dospolicyname + "\t" );
}
}
result = client.setservice_tcpb("svc1",yesnoEnum.YES);
Console.WriteLine("setservice_tcpb svc1 : " + result.message);
getserviceResult getserviceresult4 = client.getservice("svc1",false,false);
Console.WriteLine("getservice svc1 : " + getserviceresult4.message);
if ( (getserviceresult4.List != null) && (getserviceresult4.List.Length > 0)) {
for(int i =0 ; i < getserviceresult4.List.Length;i++) {
service obj;
obj = (service) getserviceresult4.List[i];
Console.WriteLine( obj.name + "\t" + obj.all + "\t" + obj.internaL + "\t" + obj.servername + "\t" + obj.servicetype + "\t" + obj.serviceconftpye + "\t" + obj.port + "\t" + obj.value + "\t" + obj.cleartextport + "\t" + obj.gslb + "\t" + obj.cachetype + "\t" + obj.maxclient + "\t" + obj.maxreq + "\t" + obj.cacheable + "\t" + obj.cip + "\t" + obj.cipheader + "\t" + obj.usip + "\t" + obj.sc + "\t" + obj.weight + "\t" + obj.sp + "\t" + obj.failedprobes + "\t" + obj.clttimeout + "\t" + obj.totalprobes + "\t" + obj.svrtimeout + "\t" + obj.totalfailedprobes + "\t" + obj.serverid + "\t" + obj.cka + "\t" + obj.tcpb + "\t" + obj.cmp + "\t" + obj.maxbandwidth + "\t" + obj.accessdown + "\t" + obj.svrstate + "\t" + obj.ipaddress + "\t" + obj.monitorname + "\t" + obj.monthreshold + "\t" + obj.monstate + "\t" + obj.monstatcode + "\t" + obj.responsetime + "\t" + obj.downstateflush + "\t" + obj.statechangetimesec + "\t" + obj.statechangetimemsec + "\t" + obj.timesincelaststatechange + "\t" + obj.tickssincelaststatechange + "\t" + obj.scpolicyname + "\t" + obj.dospolicyname + "\t" );
}
}
result = client.logout();
Console.WriteLine("logout : " + result.message);
}
catch (Exception ex) {
Console.WriteLine( "Exception: "+ex.ToString());
}
}
}
}