.NET Framework Bookmark and Share   
 index > Windows Communication Foundation > Generating proxy for wcf service which has hosted in Windows service ?
 

Generating proxy for wcf service which has hosted in Windows service ?

Hi All,

I am newly working on WCF. I have hosted my serivce both in console, and windows service. I was able to access the serivce when I run my client application by using the following code:

ChannelFactory<INormSpecifications> factoryNormSpecifications = new ChannelFactory<INormSpecifications>("");

m_netTcpProxy = factoryNormSpecifications.CreateChannel();

My host code which starts the service as follows:

hostA = new ServiceHost(typeof(BusinessServices.NormSpecificationsService));

Console.WriteLine("Object created");

hostA.Open();

It was working fine receiving messages by using the following configuration at my host as :

<system.serviceModel>

<bindings>

<netTcpBinding>

<binding name="NetTcpBinding" transactionFlow="true">

<readerQuotas maxArrayLength="50000000" />

<reliableSession enabled="true" />

</binding>

</netTcpBinding>

</bindings>

<behaviors>

<serviceBehaviors>

<behavior name="ServiceBehaviour">

<serviceMetadata />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

</serviceBehaviors>

</behaviors>

<services>

<service behaviorConfiguration="ServiceBehaviour" name="BusinessServices.NormSpecificationsService">

<endpoint address="NormSpecifications" binding="netTcpBinding" bindingConfiguration="NetTcpBinding" contract="IBusinessServiceContracts.INormSpecifications" />

<host>

<baseAddresses>

<add baseAddress="net.tcp://mietnb04:9010" />

</baseAddresses>

<timeouts closeTimeout="00:01:10" />

</host>

</service>

</services>

</system.serviceModel>

by the way I did the same end point configuration at my client side too.

I did the same configuration to my windows host and installed in the nt services. It was running fine.

Did for the client same.

But at my client side if I want to use the service by using the statements as above

ChannelFactory<INormSpecifications> factoryNormSpecifications = new ChannelFactory<INormSpecifications>("");

m_netTcpProxy = factoryNormSpecifications.CreateChannel();

its throwing an exception as

Could not connect to net.tcp://mietnb04:9010/NormSpecifications. The connection attempt lasted for a time span of 00:00:02.0229088. TCP error code 10061: No connection could be made because the target machine actively refused it.

After that I dig deep in to the problem then I found , I have to generate proxy for the service.

I didnt host my service in the IIS. But I want to generate the proxy by using the svcutil.exe to have the service proxy file at my client side.

Can any body help me out to generate the service proxy at client side by using the svcutil.exe

Regards,

venu

zoomer

Hi there,

Try adding the following additional endpoint to your app.config for your service.

<service behaviorConfiguration="ServiceBehaviour" name="BusinessServices.NormSpecificationsService">

<endpoint address="NormSpecifications" binding="netTcpBinding" bindingConfiguration="NetTcpBinding" contract="IBusinessServiceContracts.INormSpecifications" />

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

This is will allow you to use svcutil to generate proxy classed for your client.

this command should allow you to generate the proxy with default settings.

svcutil.exe net.tcp://mietnb04:9010/NormSpecifications/mex

Regards Andy

AFurnival

Hi there,

Try adding the following additional endpoint to your app.config for your service.

<service behaviorConfiguration="ServiceBehaviour" name="BusinessServices.NormSpecificationsService">

<endpoint address="NormSpecifications" binding="netTcpBinding" bindingConfiguration="NetTcpBinding" contract="IBusinessServiceContracts.INormSpecifications" />

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

This is will allow you to use svcutil to generate proxy classed for your client.

this command should allow you to generate the proxy with default settings.

svcutil.exe net.tcp://mietnb04:9010/NormSpecifications/mex

Regards Andy

AFurnival

That's correct, we don't expose a MetadataExchange endpoint by default. What Andy has suggested should work just fine.

-- Dave

Dave Cliffe - MSFT

Thanks for ur quick reply.

I did all, but still I am not able to generate the proxy, its throwing the exception as follows:

Could not connect to net.tcp://localhost:9010/NormSpecifications. The connection attempt lasted for a time span of 00:00:01.9828512. TCP error code 10061: No connection could be made because the target machine actively refused it.

The same configuration which I have done for my windows service, I did it for console application. With console as host my application is working fine by creating object with

channelfactory.

I tried to generate the proxy with the help of IIS. I have created a virtual folder and pointed that with my service project. I am using layered architecture for my project. Where I have different projects for the BL, Services, DAL and datacontracts and Iservices.

I added one .svc file with the following info :

<%@ServiceHost Service="Products.NormsSpecifications" %>

%@Assembly Name="my assembly name" %

Its throwing exception like File not found of my assembly name.

Is it because of the reference dll like datacontract dll and Iservices dll existed in the other projects.

Can any body help me out.

zoomer

Based on the error you are getting, are you sure you're pointing to the mex address and NOT your tcp endpoint? As per Andy's post:

svcutil.exe net.tcp://mietnb04:9010/NormSpecifications/mex

-- Dave

Dave Cliffe - MSFT

You can use google to search for other answers

Custom Search

More Threads

• What is the Use of ServiceContract.Namespace
• Invoke a WCF Web Service Using HTTP GET
• Using ArrayAttributes in the MessageContract
• WCF MSMQ Performances
• Help~~ Will WCF block request inside its Channel when transferMode="Streamed" if there exist stream message to transfer inside Channel?
• Questions about IAuthorizationPolicy.Evaluate method
• use header replyTo or faultTo in request-response method to change the destination of the response?
• additional information in soap message
• DataContract, inheritance, and surrogate issue...
• Type differences returned from service