Main Site Documentation

Project - DPWS Discovery demo for the Hello World sample project


I just posted DPWS Discovery demo for the Hello World sample project on Codeshare. Feel free to discuss and make suggestions here.


DPWS will always benefit from more examples, thanks


@ NickP - I am trying to open the code with VS2010 but I’m getting problems. Isn’t it possible open it with this version?


Getting discovery and announcements to work properly needed the new April 25th package. Whilst I believe it is possible to use VS2010, it is not supported so this is a VS2012 solution.


@ NickP - So, is there no way to run you project in VS2010?

Could you please run your DPWS HelloWorld Server on the Gadgeteer and try to discover it and its services with this software ( It s a very simple program, don’t need to install anything.

I’m driving myself mad trying to build a DPWS scenario and I get errors everytime and I don’t know if the mistake is in my code or in the Gadgeteer.

Thank you in advance.


@ fprado Yes dpws-explorer does find the device. It does not find metadata though because mex is not configured in the sample.

device types: {}HelloWCFDeviceType

endpoint references urn:uuid:18571766-87df-06e2-bb68-5136c48f483f

XAddresses address=, ProtocolInfo: DPWSProtocolVersion [dpwsVersion=0]


@ NickP - Thank you very much.

What is mex? How can I configure it?


@ andre.m - Could you provide some code sample to see how it works? I am traying to make discoverable a DPWS service running on a Gadgeteer (MicroFramework 4.2) but I can not find the right way to do it.

In the HelloWorldServer_WCF code example there is some code, but it isn’t present in the HelloWorldServer_MF sample, which is, at the end, the one I’m using.

            ServiceHost serviceHost = new ServiceHost(typeof(ServiceHelloWCF), baseAddress);
                Binding binding;
                DiscoveryVersion ver;

                ver = DiscoveryVersion.WSDiscovery11;
                binding = new WSHttpBinding(SecurityMode.None);

                // To enable WSDiscoveryApril2005 and Soap12WSAddressingAugust2004
                ver = DiscoveryVersion.WSDiscoveryApril2005;
                binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap12WSAddressingAugust2004, Encoding.UTF8), new HttpTransportBindingElement());
                ServiceEndpoint wsEndpoint = serviceHost.AddServiceEndpoint(typeof(IServiceHelloWCF), binding, "");
                EndpointDiscoveryBehavior endpointDiscoveryBehavior = new EndpointDiscoveryBehavior();

                // Add the discovery behavior to the endpoint.
                // Make the service discoverable over UDP multicast
                ServiceDiscoveryBehavior serviceDiscoveryBehavior = new ServiceDiscoveryBehavior();
                // Announce the availability of the service over UDP multicast
                serviceDiscoveryBehavior.AnnouncementEndpoints.Add(new UdpAnnouncementEndpoint(ver));
                // Make the service discoverable over UDP multicast.
                serviceHost.AddServiceEndpoint(new UdpDiscoveryEndpoint(ver));
                // Announce the availability of the service over UDP multicast

                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.HttpGetUrl = baseAddress;

Any help?


Up! Please help with the mex configuration (code, if possible) in order to allow DPWS metadata and hosting services to be discovered. I’m a little bit lost with the .NET MF documentation.


Sorry, you’ve probably exceeded the knowledge of 93.4% of forum watchers, as DPWS is not a very often used feature


@ Brett - Hi Brett, thanks for answering.

For sure I do not exceed that knowledge because I’m green with .NETMF and Gadgeteers and I know that featue is rarely used but maybe experienced users like @ andre.m or @ NickP that have played a little bit more with DPWS can give a hand (one more) :slight_smile:


@ fprado

DPWs services are discoverable by default. I believe the issue you are facing is that the standard 4.2 release doesn’t support UDP multicast which is a pre-requisite for discovery. You have to use the April 25th sdk release which fixes the UDP issue. Someone please correct me if I am wrong but I think you end up using the 4.2 library from the 4.3 MF release.

The “_MF” sample is based on DPWS which has discovery turned on by default. (You turn it off by setting Device.SupressAdhoc to true);

The “_WCF” sample is based on Windows Communication Framework. WCF is used for a much broader range of situations which don’t usually require discovery so the DiscoveryBehavior has to be added explicitly.

I have to take back my earlier comment about MEX not being configured; MEX is enabled by default when you call Device.Initialize. I am not sure why the dpws-explorer tool couldn’t find the MEX endpoint but the WCF client does find it.


@ NickP - Thank you very much for your answer.

So, I didn’t understand well your last comment (

So, could DPWS-Explorer get the device and services metadata in your code by default? Because mine didn’t work.

I’m also in touch with the people of DPWS-Explorer and I show them the log files I got when I tried to discover DPWS running on a Gadgeteer using DPWS Explorer (reminder: I can discover and see the device -hosting service- but I’m not able to discover the hosted services). They told me: The error is, that your device does not respond with a GetResponse.(

Right now I’m using the last April 25th SDK in MF4.2 in VS2010. I’m sorry but I am also confused about “the 4.2 library from the 4.3 MF release.” Anyway I think I’m running the last SDK with multicast fixed but maybe that’s the problem.

I know I’m a pain in the ass with this issue but you are the only people in the whole internet I can ask :slight_smile: So, if you still can give some ideas, help, support you’ll make me happy.


The GHI SDK is from 1st May (the filename has 30th April) so I think you’re a week out ! And yes I think the multicast fix was a late confirmed fix…


@ fprado

I was incorrect about MEX not being configured. Having looked at the source code, MEX IS configured out of the box with DPWS.

dpws-explorer could not get the metadata as DPWS returned a soap fault when probed. I will have to set up a wire trace and examine the soap message to see what went wrong.

That said, you do not need MEX to discover your service. The preferred discovery method is to use a probe and I can confirm that probes work.

In the demo I uploaded, the ServiceDiscoveryManager cless will find any DPWS service (host or hosted) using a probe.

In summary the steps to find a service of type ServiceInterface are in the following snippet:

Log("Starting probe for " + typeof(ServiceInterface).ToString());

FindCriteria ServiceFindCriteria = new FindCriteria(typeof(ServiceInterface));

var endPoint = new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscovery11);

endPoint.Behaviors.Add(new WorkaroundBehavior());

DiscoveryClient discoveryClient = new DiscoveryClient(endPoint);

Collection<EndpointDiscoveryMetadata> services = discoveryClient.Find(ServiceFindCriteria).Endpoints;


if (services.Count != 0)
     Log("   service found: " + services[0].Address.ToString());
                    return services[0].ListenUris[0];
      Log("   no service found");
      //       if (announcementsInProgress) SetupAnnouncementService();
      return null;


@ NickP - So, you get the same error with soap fault with the DPWS Explorer, right? Please let me know if you figure out something about this.

The problem is that I want to use clients running no .NET code but other libraries (in concrete JMEDS for Java, the one DPWS-Explorer is based on) with a DPWS server in a Gadgeteer.

Anyway, I can not run your HelloWorldClientWCF: error with the incorrect references projects (DPWSDiscoveryManager and HelloWorldClientWCF) in DemoClient. How can I re-add them?

@ Brett Thanks for the info. Anyway, I think I was wrong and I’m using the last SDK you mentioned.


@ fprado Yes I get the soap fault with DPWS explorer. Digging into the code, the DPWS MEX service on the gadgeteer is throwing a null reference exception because the GET request from dpws-explorer is not sending a replyto header.

This is technically an optional field so should be reported as a bug.

This OPTIONAL element (of type wsa:EndpointReferenceType) provides the value for the [reply endpoint] property. If this element is NOT present then the value of the [address] property of the [reply endpoint] EPR is “”.[/quote]

There may be a way to get JMEDS to add this header; I haven’t found a use for MEX so I’m not familiar with it.

Anyway, I can not run your HelloWorldClientWCF: error with the incorrect references projects (DPWSDiscoveryManager and HelloWorldClientWCF) in DemoClient. How can I re-add them?[/quote]

open the two projects in the same solution: right click the solution -> add ->existing project…

then add the references: right click on the HelloWorldClientWCF project -> add reference -> choose the projects tab


Please vote for the fix to MEX:


hi admin,
Please upload the WSDL file for the project (HelloWorldServerGadgeteer).
In my project, the fez raptor acts as WCF Server. In Slot1 of , i have connected the enc28 ethernet module.
now i want to run WCF client on a different machine.
I need WSDL file to know the end points in the format http://<ip_address:port>/uuid


Hi Shailendra

The easiest way to get the WSDL is to run the Samples\HelloWorldServer_WCF sample and browse to the uri published and append ?singleWsdl
E.g. (for me)

Obviously your ip addresses would be different.

Alternatively look at the code share I uploaded that has a complete solution configuring the endpoints via discovery here: