Wednesday, February 20, 2008

"Service Unavailable"

How do you know if WCF is installed on your machine or if WCF is registered with IIS ?

Run ServiceModelReg.exe from your command prompt with /i option to register/reregister WCF (.net 3.5) with your IIS.

Restart your IIS and then try rerun the service...hopefully this should work or atleast conifrm that you have your machine ready to execute WCF requests.

HTH - Dipesh

how do i deploy/host a WCF service on remote machine?

With the task completion of hosting WCF service on machine that has installed VS 2008 and now when you are ready to deploy this on remote machine in IIS this is what you do...
1> Publish web site (option with VS 2008) that generates compiled code,
2> Copy the files on your remote machine where you want this WCF service installed,
3> Create a virtual directory and point to the physical folder where .svc files are found.
That's it! :) It's pretty much similar to the traditional web services deployment.
before you install WCF serive on any machine ensure that you have WCF and IIS installed. (IIS 6 and above). WCF is part of .net 3.0 framework. it comes along with .net 3.5 redistributable package as well.

However, here are solutions to few issues you might encounter whilst deploying...
1> After deployment you get error "Service Unavailable" in IE.
Solution - Ensure that you have sufficent rights on the physical folder from where you are executing your service (.svc) ... specially asp_net and IIS workgroup users.

2> sometimes you may just get web configuration error as you launch WCF service in IE .svc ...
Solution - You may want to try specifying custom errors tag in web.config to have exceptions as "remoteonly" so that you can understand the unhandled exceptions thrown by IIS. Sometimes, this just solves the problem...atleast solved for me :)

Previous posts on WCF - http://archdipesh.blogspot.com/search/label/WCF
Cheers - Dipesh

Overcome slow performance with the initial WCF service load/call

So now when you are all set with "WCF service" deployment milestone :) do you experience slow performance on the initial call/load of the WCF service?
Yes, Scott mentioned in the .net roadmap one of the points of cold warmup perfomance fix this summer....till then Joel has this post which has attached warmup script files that overcomes this problem.

Refer his post to get attachments -
http://blogs.msdn.com/joelo/archive/2006/08/13/697044.aspx

HTH- Dipesh

Tuesday, February 19, 2008

Scott Gu's roadmap for .net 3.5

Congratulations to Scott Guthrie first on his new role and responsibilities... he is the man! :) btw, he is on a roll with his product roadmap of .net 3.5 this summer.

You can see details on his blog here but for sure some of these changes are huge, such as speeding up cold load of .NET applications by 25%-40%, improving WPF support...and so on.

Check this - http://weblogs.asp.net/scottgu/archive/2008/02/19/net-3-5-client-product-roadmap.aspx

Cheers - Dipesh

Convert existing asmx .net web service to WCF service in .net 3.0/3.5

If you are thinking what if i already have an existing web service .asmx which are exposed to existing clients already but still want to use the new technology infrastructure then you can do it really sweet. (why you would do that...must check new features of WCF on msdn:))

So if you have existing web service like this - http://mycompany/myWebservice.asmx
Steps to have clients use .asmx extension but behind scenes use powerful WCF here they are -
1> Decorate web service class name and web method with ServiceContract and OperationContract atrributes. For this you should add reference System.ServiceModel.dll assembly that is part of .net 3.5 framework. You can download .net 3.5 framework from to have WCF services run on your machines just fine.

Once you install you should found this installed in GAC.

here's how it looks-

using System.ServiceModel;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

[ServiceContract(Namespace="http://tempuri.org")]
public class myWebService : System.Web.Services.WebService
{
[WebMethod]
[OperationContract]
public string HelloWorld(string name)
{
return string.Format("Hello, {0}",name);
}
}

2> add this system.serviceModel section into your existing web.config of the asmx web service -




3> you can run the web service now and it should compile and run without issues with asmx extension but one more thing you would have to do to tell .net runtime to use WCF service runtime is add buildprovider under Compilation section.



4> Last but not the least modify your markup code .asmx to have something like this -% @ServiceHost language = "c#" Service="yourNamespace.ClassnameOftheService" %

This shuold help you up and running WCF service still keeping the existing asmx extension!

If you are done ...great! After i completed all the above steps i encountered pretty wierd errors saying -
Service 'myWebservice' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

Reason - that was because my web.config had wrong endpoint service name reference.
service name="myWebService" behaviorConfiguration="returnFaults"

endpoint binding="basicHttpBinding" contract="myWebService"

Rectifying that helped...

If you still continue to get error you may also want to verify that you have your config file as web.config instead of app.config.

Hope that helps!

Here are few links for further information and references used here -
http://blogs.msdn.com/wenlong/archive/2007/09/18/how-to-use-asmx-extension-to-handle-wcf-requests.aspx

http://www.topxml.com/rbnews/WSCF/WCF/re-44738_Phased-Migration-From-ASMX-to-WCF.aspx

For more on WCF visit previous posts here - http://archdipesh.blogspot.com/search/label/WCF

Cheers - Dipesh

No Web methods visible in WCF service hosted...workaround

Well, one real good thing that i liked about WCF is the ease by which you get a new WCF service running real quick. The best part is that Microsoft has provided a code template with sample methods and contracts in VS 2008. You just hit Run button and you are good to go. However, with such ease i had few problems that i ran into. First of all i started creating a WCF web service project under Web which is pretty similar to ASMX style of coding. I am still to figure out why Microsoft has provided an option to create an WCF service library (a dll for web service...huh!) Regardless, if you just run the WCF service first time ...don't be afraid if you see NONE of your web methods listed in IE for the WCF service you just created. That's by nature...ofcourse there are workarounds by which you can intercept client messages inbound and outbound. Keith has showed us a way by which you can see your web methods and actually inspect soap body and envelope going through your client.

http://keithelder.net/blog/archive/2008/01/15/How-to-Get-Around-WCFs-Lack-of-a-Preview-Web.aspx

intial post on how to start writing your own WCF service and concepts look at this video on my previous post - http://archdipesh.blogspot.com/2007/12/creating-service-with-windows.html
HTH- Dipesh

Wednesday, February 13, 2008

How to post xml file or any other file onto server through .net web services?

I was in Dallas last week and working on a release of which i was not supposed to be part of it initially and then working on a Silverlight contest (still working.) btw, you too can take part in the Silverlight contest by Microsoft here -
http://silverlight.net/Showcase/

Regardless, working little bit more on web services i figured that it is absolutely ok to pass XMl as a set of string data through .net web service.
Also, i found this interesting simple article on how to upload XML or for that matter any file onto server - http://www.c-sharpcorner.com/UploadFile/scottlysle/UploadwithCSharpWS05032007121259PM/UploadwithCSharpWS.aspx

HTH, Thanks - Dipesh

Calling .net web service through HTTP Post

Below are the steps how you would call a web service from .net code through HTTP POST -

Dim oXmlhttpCaller as Object;

' Create Object of MSXml2.XMLHTTP
Set oXmlhttpCaller = Server.CreateObject("Msxml2.XMLHTTP")

'oXmlhttpCaller.open "GET","http://localhost/HelloWorld/Service.asmx/HelloWorldWit'hCustomMessage?s_msg= Hope you like this article.", False

oXmlhttpCaller.open "POST","http://localhost/HelloWorld/Service.asmx/
HelloWorldWithCustomMessage", False

oXmlhttpCaller.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXmlhttpCaller.send("Msg= Hello World!")

HTH, in my next post i wiill try and show how to send XML message as part of your input paramter. Thanks - Dj

CRM 4.0 VPC (Virtual machine download)

Here's the latest Microsoft Dynamics CRM 4.0 (Titan) complete Virtual Machine

http://www.microsoft.com/downloads/details.aspx?FamilyID=dd939ed9-87a5-4c13-b212-a922cc02b469&DisplayLang=en

This VPC is a one computer setup with Microsoft Dynamics CRM 4.0 and associated Microsoft Dynamics CRM clients for Microsoft Office Outlook and Microsoft Internet Explorer.

This demonstration also contains Microsoft SQL Server 2005, Microsoft Visual Studio 2005, Microsoft Office Communications Server and client, Microsoft SharePoint services, and Microsoft PerformancePoint Server 2007. Full details about the image are included in the virtual machine itself.

This virtual machine will expire in April, 2009. Cheers - D