I need to do migration from ASP.NET web service to WCF. Current code is like this:
Server Side:
public class MyType
{
public int x;
public string s;
}
public class MyService : WebService
{
public MyType myObj;
[WebMethod]
[SoapHeader("myObj", Direction=SoapHeaderDirection.InOut)]
public string SomeMethod() // NO Parameter!!!
{
if (myObj.x > 5)
return myObj.s;
else
return "Less than 5";
}
}
</code>
Client Side:
MyService service = new MyService();
MyType m = new MyType();
m.x = 10;
m.s = "That's it!!!";
service.myObj = m;
string s = service.SomeMethod();
This works smoothly. Now I need to change this to WCF. Found many topics about how to sign soap header with WCF, but all are about how to use MessageContract as an attribute of a class which will be given to the operation as a parameter. Like this:
<code>
[MessageContract]
public class MyType
{
public int x;
public string s;
}
[OperationContract]
public string SomeMethod(MyType myType)
{
} </code>
But this is not what I need, my method must remain the same (with no parameter).
Few blogs talks about using WCFExtra lib or implement Client Dispatcher interface to add SOAP Header to every outgoing request. But again, I want migration of web service to WCF shouldn't affect my client, and they are not required to do any code changes, they should be able to consume the web service with .asmx extension. Also, the current web service uses MTOM and WSE-3. Is there any easy way.
Please help me with this.
I have already read following articles, but none of them talk about how to handle SOAP Header, WSE-3:
http://megakemp.com/2008/11/27/migrating-aspnet-web-services-to-wcf/
http://megakemp.com/2008/11/27/migrating-aspnet-web-services-to-wcf/
http://vikasbhardwaj15.blogspot.in/2012/05/convert-asmx-web-services-to-wcf.html
http://blogs.msdn.com/b/trobbins/archive/2006/12/02/integrating-wcf-with-your-existing-asmx-services.aspx
http://blogs.msdn.com/b/kaevans/archive/2006/10/05/phased-migration-from-asmx-to-wcf.aspx
http://www.manas.com.ar/waj/2007/05/31/asmx-to-wcf-migration/