Monday, August 29

WCF errors: simple jargon-free problem and solution approach

There are lots of big terms in internet posts about WCF but it is actually a very simple concept once you can achieve an understanding of it's fundamental ideology. Getting to the core of the methodology can be very daunting for beginners. I just thought I'd make a growing journal of errors I encountered in my first WCF implementations (which I have just discovered nicely noted in one of my old work journals. Hope these will help asomeone out there at some point....

P: Trying to load a WCF web service and getting error similar to “the runtime is built with a newer runtime…”

S: Browse to Application Pool in IIS (double click) and change the runtime to the same runtime as the one specified in your web service web.config file’s target framework declaration
(e.g. targetFramework="4.0") – This solution may lead to the next error

P: When trying to browse your web service svc file in a IIS hosting environment, you get the error HTTP Error 500.21 - Internal Server Error
Handler "svc-Integrated" has a bad module "ManagedPipelineHandler" in its module list

S: IIS is not properly registered with visual studio – Open visual studio command prompt (run as administrator if using Vista) and type aspnet_regiis.exe –i

P: trying to browse your web service svc file in a IIS hosting environment, you get the error ‘The protocol 'net.pipe' is not supported’

S: IIS 5 and 6 only support http-based bindings. Remove any bindings that do not use one of the http-based protocols to remove this error

P: wcftestclient command runs your client successfully, but once in IIS environment, you get the error ‘Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.’

S: You need to add a metadata exchange (mex) endpoint to your service config file:
Something like:
<services> 
   
<service name="NewService.Service1" behaviorConfiguration="metadataBehavior"> 
     
<endpoint  
         
address="http://localhost/MyService.svc"  
         
binding="customBinding" bindingConfiguration="jsonpBinding"  
         
behaviorConfiguration="MyService.MyService" 
         
contract="MyService.IMyService"/> 
     
<endpoint  
         
address="mex"  
         
binding="mexHttpBinding"  
         
contract="IMetadataExchange"/> 
   
</service> 
</services> 

P: you want to create  wcf service but you don't want the default tempuri.org namespace on your generated wsdl files
S: You need to add a namespace attribute to your ServiceContract declaration:
Something like:
[ServiceContract( Namespace = "http://www.mynamespace.com/myfunctions.anythingelse" )]
































No comments:

Post a Comment