Tuesday, 16 March 2010

Web Services On Devices : Getting WSDAPIs for Print Client

WSDAPI stack provided by Microsoft as part of Windows Rally technologies, is an implementation of DPWS(Devices Profile for Web Services), which defines a minimal set of implementation constraints to enable secure Web Service messaging, discovery, description, and eventing on resource-constrained devices.

If you had gone through the links, I provided in my first post on Web Services on Devices (Web Services on Devices : Environment Set Up in Windows Vista), you would have known by now, what it requires to develop a Web Service Device which hosts Web Service and a Web Service Client, which uses the services hosted on Web Service Device. In this post, I will be explaining how you can develop a Web Services client in Microsoft Windows Vista, using WSDAPIs taking the example of Print Service.

Where can I get more information on DPWS, WSDAPIs, Windows Rally Technologies?
Go to - http://www.microsoft.com/whdc/connect/rally/rallywsd.mspx

Where can I get the Print Device and Print Service Specifications for implementing Print Service and Print Service Client?

Go to - http://www.microsoft.com/whdc/connect/rally/wsdspecs.mspx, where you can download Specifications and Supporting Files for Print Device and Print Service. These schemas/specification describe the format of data being exchanged between the Web Service and Web Service Client and the interfaces which need to implemented by the Device, which provides the Print Service. After unzipping the zip file downloaded from the above link, you will find WSDPrinterService.wsdl, supporting .xsd files and WSDPrintService.doc explaining the schema. WSDPrintService.doc should give you a fair idea of what it requires to develop a Print Client based on WSD protocol.

Developing a Print Service Client, using the schema/specification just downloaded:

How do I get WSDAPIs to be called from Print Client?

Following steps explain how to go about building Print Client.
  • Get WSDPrinterService.wsdl and other .xsd files(Print Service Schema).
  • Generate a config file by running WsdCodeGen on WSDPrinterService.wsdl.
    You can find wsdcodegen.exe in "Windows SDK folder\Bin". run "wsdcodegen.exe /generateconfig:all WSDPrinterService.wsdl". This command will generate codegen.config. Make sure the directory which contains WSDPrinterService.wsdl also holds all the .xsd files from Print Service Schema as WSDPrinterService.wsdl includes those .xsd files. Otherwise, you will find that message structure elements in PrinterServiceTypeTypes.h (which gets generated in next step) will be empty.
  • Generate IDL, C++ and header files.
    run "wsdcodegen.exe /generatecode codegen.config". This command will generate the following files - PrinterServiceType.idl, PrinterServiceTypeProxy.h, PrinterServiceTypeProxy.cpp, PrinterServiceTypeTypes.h, PrinterServiceTypeTypes.cpp and PrinterServiceTypeStub.cpp. These files can be added as a part of Visual Studio project and can be built into a static library (.lib)
  • You may face problems like – not able to include PrinterServiceType.h in building the above .lib, since PrinterServiceTypeProxy includes PrinterServiceType.h, which contains the definitions for interfaces like CreatePrintJob, SendDocument etc. This and other files – PrinterServiceType_p.c and PrinterServiceType_i.c are generated by MIDL (Microsoft Interface Definition Language) compiler when building the above mentioned .lib. You may notice that, in case of above error, MIDL would have generated PrinterServiceType_h.h in the Project folder. To make sure that MIDL generates PrinterServiceType.h make the following settings changes. In Visual Studio solution explorer, right click on the Project. Select Properties, Configuration Properties, MIDL, Output, Header File. Change the value to $(InputName).h instead of $(InputName)_h.h

  • Now you are ready with required WSDAPIs to be called from your Print Client application.

    No comments:

    LinkWithin

    Related Posts with Thumbnails