Adding Service References

  • Thread starter Thread starter Peter Larsen [CPH]
  • Start date Start date
P

Peter Larsen [CPH]

Hi,

I'm trying to add a service reference to a client project (using the "Add
Service Reference" menu in the solution explorer).

I use VS2008 and dotnet 3,5 and the "WCF Service Configuration Editor"
software to setup the service project.

I have a project with two WCF endpoints (TCP and HTTP).
Then i have another project (the client) where i want to add the service
reference (the reference to my WCF enpoint(s)).

The only way i can make this works, is if i add a HTTP endpoint and setting
httpGetEnabled to true.
If i remove the HTTP endpoint from my service project (or set httpGetEnabled
to false), the client is not able to browse the service in the "Add Service
Reference" option.

My question is, how do i browse and add the service reference to my client,
if the service only have one TCP endpoint ??

Thank you in advance.
BR
Peter
 
Hello Peter,

To make Visual Studio's Add Reference Service find the WCF service, we need
to expose the corresponding mex endpoint for that WCF service. Otherwise,
ARS dialog will not find it. The mex endpoint is supposed to provide mete
data exchange to make it visible.

See the following two links,
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/9414cfc5-4cd9-4901-
a2c3-ccf9e95b6588
http://alexpinsker.blogspot.com/2009/06/howto-publish-metadata-for-nettcp.ht
ml

If you have any future questions or concerns on this, please feel free to
let me know!

Have a nice day, Sir!


Best regards,
Colbert Zhou
Microsoft Online Support Team
 
Hi Colbert,

Thanks for the reply.

So what you say is this: if i don't add a http endpoint, i must add a
mexTcpBinding endpoint instead (that is if i want ASR to work), right ??
Do i need to create a new service behavior configuration/element for each
endpoint i have or is it ok to add a service behavior to more than one
endpoint ??

BR
Peter
 
So what you say is this: if i don't add a http endpoint, i must add a
mexTcpBinding endpoint instead (that is if i want ASR to work), right ??

Yes.
endpoint i have or is it ok to add a service behavior to more than one
endpoint ??

We do not need to add another new service behavior. It is OK to map one
service behavior to more than one endpoint.

Actually the following is test in my side.
In the app.config,
---------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.MetadataBehavior">
<serviceMetadata httpGetEnabled ="false " httpsGetEnabled ="false
" />
</behavior>
</serviceBehaviors>
</behaviors>

<services>
<service name="WcfService1.Service1"
behaviorConfiguration="WcfService1.MetadataBehavior">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:5555/WcfService1"/>
</baseAddresses>
</host>
<!-- Endpoint for the service. -->
<endpoint address="service" binding="netTcpBinding"
contract="WcfService1.IService1" />
<!-- Metadata endpoint. -->
<endpoint address="mex" binding="mexTcpBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>
-----------------------------------------------------

And we need to write the following codes to start it,
---------------------------------
static void Main(string[] args)
{
ServiceHost serviceHost = new
ServiceHost(typeof(WcfService1.Service1));
serviceHost.Open();
while (true)
{
}
}
----------------------------------

After the above application starts it start the WCF service. So I can find
this WCF service in Add Service Reference in the Visual Studio from my test
client.


Best regards,
Colbert Zhou
Microsoft Online Support Team
 
Back
Top