WS-Discovery

Martin Waller 1 Reputation point
2021-01-28T13:21:00.067+00:00

Hi,

I'm having issues finding and then talking to my Brother DCP-7055W printer. I'm using code such as:

        DiscoveryEndpoint discoveryEndpoint = new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscoveryApril2005);
        DiscoveryClient discoveryClient = new DiscoveryClient(discoveryEndpoint);

        FindCriteria findCriteria = new FindCriteria();
        findCriteria.Duration = TimeSpan.FromSeconds(5);
        findCriteria.ContractTypeNames.Add(new System.Xml.XmlQualifiedName("PrintDeviceType", "http://schemas.microsoft.com/windows/2006/08/wdp/print"));

        FindResponse findResponse = discoveryClient.Find(findCriteria);

to doscover my printer. This seems to return two endpoints one for my Web enabled WebCam and one for my printer. The printer entry three ContractTypeNames, one for devprof:Device, one for print:PrintDeviceType, and one for scan:ScanDeviceType which matches my expectations. The associated endpointAddress contains a URI that looks like:

{urn:uuid:e3248000-80ce-11db-8000-008092965229}

I was half expecting this to be an IP address or similar http://192.168.1.143 would be nice as that's the address of the printer.

My question is two fold, why does the line:

findCriteria.ContractTypeNames.Add(new System.Xml.XmlQualifiedName("PrintDeviceType", "http://schemas.microsoft.com/windows/2006/08/wdp/print"));

not limit the findings to just my printer? And how do I obtain the actual IP address?

Many thanks

Martin

Windows for business | Windows Server | User experience | Print jobs
Developer technologies | C#
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2021-01-29T06:37:34.69+00:00

    Hi,

    not limit the findings to just my printer

    As per below article, a WSDAPI client first queries the device for complete descriptions of its services. While devices may include zero or more services. So, the WebCam might also include service that support scanning or any other related service.
    https://learn.microsoft.com/en-us/windows/win32/wsdapi/about-web-services-for-devices

    how do I obtain the actual IP address

    From the description "When a device is manufactured, it is given a globally unique identifier, represented as a UUID URI. This identifier will never change for the device. When the device is powered on, it will always announce its logical address via a WS-Discovery Hello message", I think it should be an expected behavior that the associated endpoint Address contains a URI.

    Hope the information can help you.

    Thanks,
    Eleven


    If the Answer is helpful, please click "Accept Answer" and upvote it. Thanks.

    0 comments No comments

  2. Martin Waller 1 Reputation point
    2021-01-29T17:17:54.153+00:00

    Hi Eleven,

    Many thanks for the answer, I'll check out the document.

    Martin


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.