I moved my WCF service created last week from in-proc and custom standalone server to IIS.Step 1: VS2008, File, New WebSite, WCF Service. Add the previous MyService project into reference list.
Step 2: New file: MyGreetingService.svc
<%@ ServiceHost Language=”C#” Debug=”true” Service=”MyService.MyGreetingService” %>
Step 3: Web.config:
<system.serviceModel>
<services>
<service behaviorConfiguration=”MyGreetingServiceBehavior” name=”MyService.MyGreetingService”>
<endpoint address=”" binding=”wsHttpBinding” contract=”MyService.IMyGreetingService”>
<identity>
<dns value=”localhost”/>
</identity>
</endpoint>
<endpoint address=”mex” binding=”mexHttpBinding” contract=”IMetadataExchange”/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name=”MyGreetingServiceBehavior”>
<serviceMetadata httpGetEnabled=”true”/>
<serviceDebug includeExceptionDetailInFaults=”false”/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Step 4: Add mapping in IIS Virtual Directory config: map .svc to aspnet. I got (405) Method Not Allowed at this point. Checked the post on MS forum, running the CleanIISScriptMaps.exe didn’t fix my problem, but manually mapping .svc extension to aspnet_isapi.dll resolved this problem.
Step 5: Test this WCF Service in browser: http://localhost/MyWCFServiceOnWeb/MyGreetingService.svc
Step 6: Client side config:
<endpoint name =”MyIISEndPoint”
address =”http://localhost/MyWCFServiceOnWeb/MyGreetingService.svc”
binding =”wsHttpBinding”
contract =”MyService.IMyGreetingService”
/>
Step 7: Client side service calling code.
private void btnWCFIISOK_Click(object sender, EventArgs e)
{
WCFService1Client proxy = new WCFService1Client(“MyIISEndPoint”);
lblMessages.Text = proxy.GetGreetingMessagesFor(txtUserName.Text);
proxy.Close();
}
Done.
Juval Lowy said IIS Hosting WCF process is lauched automatically upon the first client request. But how can I tell? I need something like an IIS management console to monitor all the server side services.
Launch Microsoft service configuration editor – svcConfigEditor.exe in SDK folder, open the IIS WCF service.
Set trace in Diagnostics item.
Save config. Re-launch the client app. Check the new generated svclog files.
There is another tool called Microsoft Service Trace Viewer – SvcTraceViewer.exe from SDK, which is dedicate to open this kind of log file. The interface is graphic, but I think jagmanager is way better.
CSLA Wcf Host in trace viewer.



One Trackback/Pingback
[...] / Trace WCF Service Filed under: WCF — Frank Mao @ 9:50 am I posted my experience on Wcf log/Trace before, today I found WMI tool can actually monitor the Wcf Host itself, (not the call from [...]