tags:

views:

12

answers:

1

I have an external xml file which declare WS-policy as shown below:

<?xml version="1.0" encoding="utf-8"?>
<wsp:Policy xmlns:wsp="http://www.w3.org/2006/07/ws-policy" 
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" 
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
xmlns:wsrr="http://www.ibm.com/xmlns/prod/serviceregistry/6/2/wspolicy" 
xmlns:wsoma="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" 
wsrr:policyClassDomain="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" targetNamespace="http://mycommon/Policy"&gt;
 <wsp:Policy wsu:Id="WSHttpsBinding_policy">
 <wsp:ExactlyOne>
  <wsp:All>
  <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;
   <wsp:Policy>
   <sp:TransportToken>
    <wsp:Policy>
    <sp:HttpsToken RequireClientCertificate="false" />
    </wsp:Policy>
   </sp:TransportToken>
   <sp:AlgorithmSuite>
    <wsp:Policy>
    <sp:Basic256 />
    </wsp:Policy>
   </sp:AlgorithmSuite>
   <sp:Layout>
    <wsp:Policy>
    <sp:Strict />
    </wsp:Policy>
   </sp:Layout>
   </wsp:Policy>
  </sp:TransportBinding>
  <wsaw:UsingAddressing />
  </wsp:All>
 </wsp:ExactlyOne>
 </wsp:Policy>
 <wsp:Policy wsu:Id="WSHttpBinding_policy">
 <wsp:ExactlyOne>
  <wsp:All>
  <wsaw:UsingAddressing />
  </wsp:All>
 </wsp:ExactlyOne>
 </wsp:Policy>
 <wsp:Policy wsu:Id="basicHttpsBinding_policy">
 <wsp:ExactlyOne>
  <wsp:All>
  <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;
   <wsp:Policy>
   <sp:TransportToken>
    <wsp:Policy>
    <sp:HttpsToken RequireClientCertificate="false" />
    </wsp:Policy>
   </sp:TransportToken>
   <sp:AlgorithmSuite>
    <wsp:Policy>
    <sp:Basic256 />
    </wsp:Policy>
   </sp:AlgorithmSuite>
   <sp:Layout>
    <wsp:Policy>
    <sp:Strict />
    </wsp:Policy>
   </sp:Layout>
   </wsp:Policy>
  </sp:TransportBinding>
  </wsp:All>
 </wsp:ExactlyOne>
 </wsp:Policy>
 <wsp:Policy wsu:Id="TcpBinding_policy">
 <wsp:ExactlyOne>
  <wsp:All>
  <msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1" />
  <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;
   <wsp:Policy>
   <sp:TransportToken>
    <wsp:Policy>
    <msf:WindowsTransportSecurity xmlns:msf="http://schemas.microsoft.com/ws/2006/05/framing/policy"&gt;
     <msf:ProtectionLevel>EncryptAndSign</msf:ProtectionLevel>
    </msf:WindowsTransportSecurity>
    </wsp:Policy>
   </sp:TransportToken>
   <sp:AlgorithmSuite>
    <wsp:Policy>
    <sp:Basic256 />
    </wsp:Policy>
   </sp:AlgorithmSuite>
   <sp:Layout>
    <wsp:Policy>
    <sp:Strict />
    </wsp:Policy>
   </sp:Layout>
   </wsp:Policy>
  </sp:TransportBinding>
  <wsaw:UsingAddressing />
  </wsp:All>
 </wsp:ExactlyOne>
 </wsp:Policy> 
</wsp:Policy> 

How can I link it to the WSDL document generated for my service?

A: 

What do you need to link an external WS-Policy from the generated WSDL? Unless it matches your WCF security settings in your binding (in which case, it would already be including the required policy elements in it), that's not really going to work.

If you're still keen on forcing the external ws-policy into the generated WSDL, the way to do it would be with a custom IWsdlExportExtension implementation.

tomasr
IWsdlExportExtension doesn't export custom policy assertions and I learnt from MSDN site that I should use IPolicyExportExtension. But have no ideas on how to use it. If you have any suggestions reg. this interface usage please let me know