namespace LearnCSharp
{
public class MyClass
{
public void doWork()
{
}
}
static public class MyClassExt
{
static public void extentionMethod(this object myclass)
{
}
}
public class UseIt
{
public void Yahoo()
{
new MyClass().doWork();
MyClass myClass = new MyClass();
myClass = null;
myClass.extentionMethod();
string s = null;
s.extentionMethod();
}
Monday, March 23, 2009
wsHttping Binding WCF service
I was helping out some of my team mates to get WCF webservice using wsHttpBinding working when called using Axis 2 client.
They were trying to send some huge xml data(as string) as parameter of web method. They could not use basicHttpBinding because it has limit of 7 KB or something.
Wcf client generated using svcutil was working fine, but Axis2 client was not working. We then used tcptrace and looked at Soap envelope which is generated by Axis 2 client and wcf client. We found that one generated by Axis did not have soap addressing header.
So after enabling Axis 2 addressing module , we could get Axis2 client working with WCF .net service using wsHttpBinding.
They were trying to send some huge xml data(as string) as parameter of web method. They could not use basicHttpBinding because it has limit of 7 KB or something.
Wcf client generated using svcutil was working fine, but Axis2 client was not working. We then used tcptrace and looked at Soap envelope which is generated by Axis 2 client and wcf client. We found that one generated by Axis did not have soap addressing header.
So after enabling Axis 2 addressing module , we could get Axis2 client working with WCF .net service using wsHttpBinding.
Thursday, March 19, 2009
I started working on .net project since last 8 months. Delegate is something interesting
[TestFixture]
Example 1: Simple Delegate
public class DeletegateTest
private delegate int MyDelegate(string some);
[Test]
public void SampleTest()
{
}
private int mydelegatemethod(string s)
{
Console.WriteLine("I got:" + s);
return 1;
}
private void doWork(MyDelegate del)
{
del("sandeep");
}
}
Example 2: Same Simple Delegate Simplified
TestFixture]
public class Delete
{
private delegate int MyDelegate(string some);
[Test]
public void SampleTest()
{
doWork(mydelegatemethod);
}
private int mydelegatemethod(string s)
{
Console.WriteLine("I got:" + s);
return 1;
}
private void doWork(MyDelegate del)
{
del("sandeep");
}
}
Example 3: Same example With Lamda
[TestFixture]
public class Delete
{
private delegate int MyDelegate(string some);
[Test]
public void SampleTest()
{
doWork((s) =>
{
Console.WriteLine("I got:" + s);
return 1;
});
}
private void doWork(MyDelegate del)
{
del("sandeep");
}
}
Example 4: With Anonymous method
[TestFixture]
public class Delete
{
private delegate int MyDelegate(string some);
[Test]
public void SampleTest()
{
doWork(delegate(string s)
{
Console.WriteLine("I got:" + s);
return 1;
});
}
private void doWork(MyDelegate del)
{
del("sandeep");
}
}
[TestFixture]
Example 1: Simple Delegate
public class DeletegateTest
private delegate int MyDelegate(string some);
[Test]
public void SampleTest()
{
doWork(mydelegatemethod);
}
private int mydelegatemethod(string s)
{
Console.WriteLine("I got:" + s);
return 1;
}
private void doWork(MyDelegate del)
{
del("sandeep");
}
}
Example 2: Same Simple Delegate Simplified
TestFixture]
public class Delete
{
private delegate int MyDelegate(string some);
[Test]
public void SampleTest()
{
doWork(mydelegatemethod);
}
private int mydelegatemethod(string s)
{
Console.WriteLine("I got:" + s);
return 1;
}
private void doWork(MyDelegate del)
{
del("sandeep");
}
}
Example 3: Same example With Lamda
[TestFixture]
public class Delete
{
private delegate int MyDelegate(string some);
[Test]
public void SampleTest()
{
doWork((s) =>
{
Console.WriteLine("I got:" + s);
return 1;
});
}
private void doWork(MyDelegate del)
{
del("sandeep");
}
}
Example 4: With Anonymous method
[TestFixture]
public class Delete
{
private delegate int MyDelegate(string some);
[Test]
public void SampleTest()
{
doWork(delegate(string s)
{
Console.WriteLine("I got:" + s);
return 1;
});
}
private void doWork(MyDelegate del)
{
del("sandeep");
}
}
Subscribe to:
Posts (Atom)