none
How WS-Policy and WS-PolicyAttachment is supported in WCF?

    Question

  • Can someone tell me how WS-Policy and WS-PolicyAttachment are supported in WCF?
    Are there any classes that can load an WS-Policy file and produce the required Policy Object Model? Also is there any support for Normalize and Merge operations (as specified by the WS-Policy spec? How can we check that the Service Provider Policy are compatible with the Service Consumer Policies?
    Are there any classes that can load an WS-PolicyAttachment file and produce the required Policy Object Model to ease processing of the referenced policies?
    I did extensive Web search and browsed WCF classes but I could not find any pointers to the above! I appreciate your help in providing any useful pointers/links to answer the above questions.
    Thanks
    Karim
    mercredi 9 août 2006 09:08

Réponses

  • Hi Karim,

    >Are there any classes that can load an WS-Policy file and produce the required Policy Object Model?

    WCF exposes a PolicyAssertionCollection type, which is just a collection of XmlElements.  The WsdlImporter type handles importing WSDL documents with attached policy, and will automatically resolve policy references and policy normalization.  You can register an IPolicyImportExtension with the WsdlImporter in order to process custom policy assertions. 

    >Also is there any support for Normalize and Merge operations as specified by the WS-Policy spec?

    The ImportPolicy method on the IPolicyImportExtension interface takes a PolicyConversionContext that gives you access to a single normalized policy alternative for each WSDL policy subject.  The ImportPolicy method is called repeatedly for all combinations of normalized policy alternatives.  We don't actually normalize wsp:Optional, because we have found that it is convenient to know when the service is trying to express optionality.  We only support merging policies attached to the wsdl binding and to the wsdl port.  WCF only attaches policies in the WSDL binding.

    >How can we check that the Service Provider Policy are compatible with the Service Consumer Policies?

    WCF V1 doesn't include any support for explicitly defining a consumer policy.  You can, however, write validation code in a behavior that examines the relevant runtime pieces.  We will ship a sample in the SDK that shows how to do this.

    >Are there any classes that can load an WS-PolicyAttachment file and produce the required Policy Object Model to ease processing of the referenced policies?

    Yes, the WsdlImporter handles importing policies attached to WSDL documents. 

    >I did extensive Web search and browsed WCF classes but I could not find any pointers to the above! I appreciate your help in providing any useful pointers/links to answer the above questions.

    We are actively working on improving our documentation, so you should expect dramatic improvements in the SDK by the time we ship.  Please let me know if you have further questions. 

     Daniel Roth

    mercredi 9 août 2006 22:42

Toutes les réponses

  • Karim,

    I'm not the guru on policy -- which means I'll ask Dan to wade in to all your specific questions. But you can test things and see how it works. I've written a couple of blog entries recently on policy export (here) and import (here). See what you can come up with. Those posts are more operational than conceptual, so there are a bunch of things that can be done there I didn't touch upon, but have recently put into the documentation.

    Hope this helps, Ralph

    mercredi 9 août 2006 16:07
  • Hi Karim,

    >Are there any classes that can load an WS-Policy file and produce the required Policy Object Model?

    WCF exposes a PolicyAssertionCollection type, which is just a collection of XmlElements.  The WsdlImporter type handles importing WSDL documents with attached policy, and will automatically resolve policy references and policy normalization.  You can register an IPolicyImportExtension with the WsdlImporter in order to process custom policy assertions. 

    >Also is there any support for Normalize and Merge operations as specified by the WS-Policy spec?

    The ImportPolicy method on the IPolicyImportExtension interface takes a PolicyConversionContext that gives you access to a single normalized policy alternative for each WSDL policy subject.  The ImportPolicy method is called repeatedly for all combinations of normalized policy alternatives.  We don't actually normalize wsp:Optional, because we have found that it is convenient to know when the service is trying to express optionality.  We only support merging policies attached to the wsdl binding and to the wsdl port.  WCF only attaches policies in the WSDL binding.

    >How can we check that the Service Provider Policy are compatible with the Service Consumer Policies?

    WCF V1 doesn't include any support for explicitly defining a consumer policy.  You can, however, write validation code in a behavior that examines the relevant runtime pieces.  We will ship a sample in the SDK that shows how to do this.

    >Are there any classes that can load an WS-PolicyAttachment file and produce the required Policy Object Model to ease processing of the referenced policies?

    Yes, the WsdlImporter handles importing policies attached to WSDL documents. 

    >I did extensive Web search and browsed WCF classes but I could not find any pointers to the above! I appreciate your help in providing any useful pointers/links to answer the above questions.

    We are actively working on improving our documentation, so you should expect dramatic improvements in the SDK by the time we ship.  Please let me know if you have further questions. 

     Daniel Roth

    mercredi 9 août 2006 22:42
  • Thank you very much Daniel for your helpful answers, I will check and experiment the ideas mentioned in your reply. I will have more questions as soon as I further study the WCF policy-support as advised in your reply.

    Thanks

    Karim

    jeudi 10 août 2006 01:54
  • Hi,

    Regarding the question:

    >Are there any classes that can load an WS-PolicyAttachment file and produce the required Policy Object Model to ease processing of the referenced policies?

    Yes, the WsdlImporter handles importing policies attached to WSDL documents. 

    Can you specify how we can get this working? I try with adding an xml file with the policy in it like:   

    <wsp:PolicyAttachment...[all the policy here]

    Using something like:

    XmlDocument policyAttachment = new XmlDocument();
    policyAttachment.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "policies.xml"));
    context.GetBindingAssertions().Add(policyAttachment.DocumentElement);
    
    

    inside the ExportPolicy method of IPolicyExportExtension but then I cannot get the policy back on the import side.

    Any ideas?

    Thanks a lot,

    Hernan

     
    mardi 11 mai 2010 00:10