FHeNuS

Good afternoon fellows, i have a little question, it shouldn¡¯t be a problem to all the experts that come to this forum. ;D

What i want to know is this: I have a Windows Forms application that consumes some WCF Services that are exposed using WebServices. That works great. YHUUUUUUU... But its a really anoying proccess to debug it (every time i have to attach the Visual Studio Debugger to the aspnet_wp manually). So what i was thinking it was depending on the binding configuration in the app.config (debug) i would use these services in a self-hosted environment or web services. I could host the service in my Windows Forms application, but the problem is, i can¡¯t understand how i consume this service.

To consume a WCF service normally its used a proxy class, and normally this proxy class is generated using svcutil.exe. I could generate the proxy class connecting to the Web Service Host and then was thinking in changind the config that the svcutil.exe generated, so it would use the Windows Form Host. But i don¡¯t really know HOW to do this.

Do i have to use the NetTcpBinding for this feature Because as far as i know i have to do some kind of mapping soh when a client tries to connect to the service address, the call is transfered to my Windows Forms Application hosting the service.

If anyone has another idea to surpass the "attach to proccess" thing i would be really glad too.

Im using Windows XP Pro SP 2 (developer machine, since this feature its only "required" at develop/testing times)

Thanks anyway. :D




Re: Windows Communication Foundation (Indigo) Consuming a Service in the self-hosted application!

JDPeckham

creating a proxy via svcutil (or via vs2005 extensions) works the same way whether you're using self hosted or IIS hosted endpoints. You have to have metadata exchange enabled first of all. Then you just point svcutil at the endpoint.

 

For example, in your IIS hosted app you might have this:

<services>

<service behaviorConfiguration="MetaDataBehavior" name="Services.ServiceImplementation">

<endpoint address="http://localhost/services/service.svc"

binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfig"

name="wsHttpStarSearcher" contract="Services.IService" />

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

</service>

</services>

<behaviors>

<serviceBehaviors>

<behavior name="MetaDataBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

</serviceBehaviors>

</behaviors>

So you point your svcutil at http://localhost/services/service.svc

Just copy the same <system.serviceModel> xml from your web.config into your self hosted app.config and it will work the same way.

Keep in mind if you have IIS running you can't host it at the same location as IIS is already hosting something, so you'd have to change the port... maybe like this:

http://localhost:8000/services/service.svc