WS-Discovery Sample Implementation

This sample is no longer supported, please use WS-Discovery implementation shipped as part of .NET 4.0 (https://msdn.microsoft.com/en-us/library/dd288697.aspx).

 

The sample implementation of WS-Discovery protocol is now available at https://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=netfxsamples&DownloadId=3940

Using this sample you can publish and find WCF services using WS-Discovery protocol. Please either submit your feedback directly on the sample page or send it to me (vipul.modi@microsoft.). Your feedback will help in designing the discovery APIs for the next release.

Comments

  • Anonymous
    December 22, 2006
    WPF/E Pad [Via: dwahlin ] Recipe: Deploying a SQL Database to a Remote Hosting Environment (Part 1)...

  • Anonymous
    January 17, 2007
    Hello Vipul, great stuff. I was about to implement this myself. Also the sample on how to use it with a custom peer resolver is exactly on the track I would have aproaced as well. Don't be discouraged about the lack of comments. People are simple still not there (WCF + peer to peer + WS Discovery) Do you have any plans on supporting the Discovery proxy ? The only small grip I have is the lack of code comments, but unterstanding he code is managable Keep up the good work

  • Anonymous
    January 26, 2007
    The comment has been removed

  • Anonymous
    March 12, 2007
    Vipul: Great library. I added it to a target solution and attached the [Discoverable] attribute to a service I'm writing then created an NUnit test  that uses the library and ServiceFinder() to probe for the service. this works great, finding service endpoints in my local network. Now I'm trying to get a WCF client that my team is creating to use the library, but probes do not return any end points. Should I turn on tracing in the client app we're writing to see where the probes are failing? Is this some sort of scoping problem. Any hints would be appreciated. Thanks.

  • Anonymous
    April 30, 2007
    Charles, The UDP multicast is limited to the local subnet. It is not recommended to forward the multicast packets across the networks. If you would like to cross the network I would suggest using peernet channel or implementing discovery proxy. Thanks, Vipul

  • Anonymous
    June 20, 2007
    I have been using this resource for a while, but I recently noticed the following assembly load errors when I modify the default IDE exceptions handling. With the default settings the error goes unnoticed and the samples run fine. BindingFailure was detected Message: The assembly with display name 'Microsoft.ServiceModel.Samples.Discovery.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.ServiceModel.Samples.Discovery.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.ServiceModel.Samples.Discovery.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' === Pre-bind state information === LOG: User = Ritarichard LOG: DisplayName = Microsoft.ServiceModel.Samples.Discovery.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, processorArchitecture=MSIL (Fully-specified) LOG: Appbase = file:///C:/Users/Public/Documents/VS 2005 Projects/VS 2005 Lib/Discovery/examples/GettingStarted/client/bin/ LOG: Initial PrivatePath = NULL Calling assembly : System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. === LOG: This bind starts in default load context. LOG: Using application configuration file: C:UsersPublicDocumentsVS 2005 ProjectsVS 2005 LibDiscoveryexamplesGettingStartedclientbinclient.vshost.exe.config LOG: Using machine configuration file from C:WindowsMicrosoft.NETFrameworkv2.0.50727configmachine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///C:/Users/Public/Documents/VS 2005 Projects/VS 2005 Lib/Discovery/examples/GettingStarted/client/bin/Microsoft.ServiceModel.Samples.Discovery.XmlSerializers.DLL. LOG: Attempting download of new URL file:///C:/Users/Public/Documents/VS 2005 Projects/VS 2005 Lib/Discovery/examples/GettingStarted/client/bin/Microsoft.ServiceModel.Samples.Discovery.XmlSerializers/Microsoft.ServiceModel.Samples.Discovery.XmlSerializers.DLL. LOG: Attempting download of new URL file:///C:/Users/Public/Documents/VS 2005 Projects/VS 2005 Lib/Discovery/examples/GettingStarted/client/bin/Microsoft.ServiceModel.Samples.Discovery.XmlSerializers.EXE. LOG: Attempting download of new URL file:///C:/Users/Public/Documents/VS 2005 Projects/VS 2005 Lib/Discovery/examples/GettingStarted/client/bin/Microsoft.ServiceModel.Samples.Discovery.XmlSerializers/Microsoft.ServiceModel.Samples.Discovery.XmlSerializers.EXE. The original error I was trying to debug was something like "Via cannot be anonymous" (logical enough but I could see how this suddenly arose?).

  • Anonymous
    June 21, 2007
    OK scrub that. The exception is an expected buglet. See http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=957134&SiteID=1

  • Anonymous
    June 21, 2007
    OK this is the error I was initially trying to debug. I use the Service Publisher example exactly as distributed except that I use config not code.  The Servicee Publisher starts up ok but when I look in the trace log I see: The message with Action 'http://schemas.xmlsoap.org/ws/2005/04/discovery/Hello' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None). Then I start up the Service Finder. It finds the service ok but when I look in the Service trace log again I see: The 'Via' property on the message is set to Anonymous Uri 'http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous'. Please set the 'Via' property to a non-anonymous address as message cannot be addressed to anonymous Uri on server side composite duplex channels. What's going on?

  • Anonymous
    June 21, 2007
    The first error is due to the fact that both announcement(Hello/Bye) and discovery (Probe/Resolve) messages are send to the same multicast address. This means that the service listening for the Probe/Resolve message will get the Hello/Bye message as well. But since the find contract does not have an operation defined for this action you get this error. One way to remove this error is to add Hello, Bye operations in the find contract and ignoring them in the implementation. I will look at the second error message and let you know. Thanks, Vipul

  • Anonymous
    August 07, 2007
    Hi. Really great work. I'm trying to use this WS-Discovery with some DPWS devices, and it works great, but I didn't manage to get the Metadata correctlyafteawards. Do you know any detail about WS-MetadataExchange (DPWS specific)? Best Regards DaCosta

  • Anonymous
    December 06, 2007
    Don't support IIS?

  • Anonymous
    December 26, 2007
    The comment has been removed

  • Anonymous
    January 07, 2008
    Hi, I am having problems with the default UPD / HTTP implementation.  I have a win form app talking to a webservice and I have decorated the service with the discoverable attribute.  I am then doing a ServiceFinder Probe using a match criteria but I get no services returned.  I have debugged and and the client is successfully multicasting the probe and the service is successfully receiving and processing the probe.  However no services are returned.  Using wireshark I have seen that the service is successfully sending hello / bye messages and the client is successfully probing however no response? Any suggestions would be greatly appreciated. Kind Regards, Luke Cloudsdale - C9

  • Anonymous
    February 01, 2008
    Hi Just a quick question, in WS-Discovery protocol implementation, can we ommit one of the constraints in the matching criteria on probe message... lets say <d:Probe> <d:Types> kgh32k43kh423 </d:Types> </Probe:> will it work? my interpretation is the ProbeMatch message should include all the target service(s) that match this type constraints regardless the scope... in addtion, can it also apply on type... lets say what if I ommit the type & specify one scope in the Probe message. please correct me. /rahul

  • Anonymous
    February 13, 2008
    Fixed it now, Seems to be a firewall issue with port 8000. Cheers, Luke Cloudsdale - C9

  • Anonymous
    March 19, 2008
    Hi, Thanks for the implementation of WS-Discovery. I'm able to build and run the applications succesfully in my Laptop. But the actual problem is when I run the service in one machine and client in another machine. I have connected two laptops two one Cisco switch. Both are in same VLAN and can ping each other. Now, in the first laptop I ran the service and second laptop I ran client. Client shows message "No Services found". I have used wireshark in both machines to capture packets, and the first laptop (where service is running) receives the WS-Discovery packet sent on port 3702. However, no other transactions after that. I have disabled firewalls in both machines. Could you please through some light on what may going wrong here?

  • Anonymous
    March 24, 2008
    I just solved the problems associated with running the application in two different machines. Thanks

  • Anonymous
    April 28, 2008
    Hi, Thanks for the sample. Like Kiran Pratapagiri, I'm getting the 'No services found' message when running using 2 different machines that are on the same subnet. Kiran, if you're reading this please post up how you resolved the issue. Thanks

  • Anonymous
    June 05, 2008
    Regarding the question below: Yes you can omit any of the constraints that you do not want to match. You can even omit all of the constraints in which case you will be able to discover all of the services.


Hi Just a quick question, in WS-Discovery protocol implementation, can we ommit one of the constraints in the matching criteria on probe message... lets say <d:Probe> <d:Types> kgh32k43kh423 </d:Types> </Probe:> will it work? my interpretation is the ProbeMatch message should include all the target service(s) that match this type constraints regardless the scope... in addtion, can it also apply on type... lets say what if I ommit the type & specify one scope in the Probe message. please correct me. /rahul

  • Anonymous
    June 05, 2008
    James, Please make sure that the 3702 UDP port is opened for firewall on the service machine and port 8000 is opened on the client machine for the service to respond back. Vipul

Hi, Thanks for the sample. Like Kiran Pratapagiri, I'm getting the 'No services found' message when running using 2 different machines that are on the same subnet. Kiran, if you're reading this please post up how you resolved the issue. Thanks

  • Anonymous
    August 23, 2008
    I am running the sample w/o changes in Visual Studio 2008 SP1. When I launch the ICalculator service and client, I get the following error: "There was no endpoint listening at http://black2:8000/Discovery/21a6b768-7a72-4de7-940f-bd4767bbc800/31828387-846a-433a-a72b-d9b230d5919f that could accept the message. This is often caused by an incorrect address or SOAP action." Upon closer inspection, it looks like the initial probe from the client finds the server, but the server cannot respond because the response endpoint created by the DuplexChannelFactory doesn't exist -- I tried accessing the response endpoint via IE but received an HTTP 404 (not found) error. I am able to access the service via IE, however.

  • Anonymous
    August 24, 2008
    The comment has been removed

  • Anonymous
    August 24, 2008
    It must have been #1 above because I added black2 to my hosts file so it could resolve and everything started working perfectly.

  • Anonymous
    November 27, 2008
    Are we going to re-invent UPnP all the way to run on top of HTTP ? We have added: Eventing, Discovery and Control ( common WS interfaces ).

  • Anonymous
    April 13, 2009
    BizTalk RFID ships a Discovery library that provides an easy interface to leverage WS-Discovery to discover

  • Anonymous
    April 24, 2009
    I have a question... I am trying to use this example to find network printers... when i start the servicefinder.exe it sends the soap packet thru a port 'xyz' to 3702. It receives the replies from port 8000. But the printers replies to port 'xyz'. So how do i modify the code so tat the servicefinder.exe listens to port it initially sent the msg from 'xyz'? is this possible?  

  • Anonymous
    May 28, 2009
    Thanks for the post. I am new to this whole world of web services and was trying to find some good example. Your article gave me a good understanding...

  • Anonymous
    June 29, 2009
    Hi, thanks for Discovery sample. It's really usuaful. I created Client and Service using sample. I am wondering about compatibility with vs 2010. I tried to create client on VS2010 Beta. IF i create client and service in 2010 it works fine. but if i create discovery service using ur sample code and client using vs2010 beta. It throws CommunicationException as below.. Addition info: The 'To' header on the message is set to Anonymous Uri...Please set the 'To' header to a non-anonymous address as message cannot be addressed to anonymous Uri on server side composite duplex channels.

  • Anonymous
    December 22, 2010
    I am not sure what I am doing wrong, but I have the client and service running on the same machine just fine, when I have them running on separate computers (on the same subnet) client invokes the service but comes back with an error message: An unhandled exception of type 'System.ServiceModel.Security.SecurityNegotiationException' occurred in mscorlib.dll Additional information: The caller was not authenticated by the service. Could you please provide some information on this issue? Also when setting the ports on the Windows Firewall which ports do you exactly set for inbound and outbound exceptions on the client and service machines. Are these ports configurable? Thanks in advance.

  • Anonymous
    December 27, 2010
    WS-Discovery was approved as an OASIS standard last year (docs.oasis-open.org/.../01). Discovery functionality was shipped as part of .NET 4.0 (msdn.microsoft.com/.../dd288697.aspx). The current sample implementation is no longer supported. Please use .NET 4.0 for all of the service and device discovery needs, it is more robust, interopreable and fully supported implementation.