本文介绍了WSDL-在一个或多个外部xml文件中添加对策略的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我已经在网上搜索了,但没有找到任何有效的方法.

I've searched along the web, but didn't find anything that works well.

我有一个声明了某些WS *策略的外部xml文件:

I have an external xml file which declare some WS* policy:

 

<?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">
 <wsp:Policy wsu:Id="WSHttpsBinding_policy">
 <wsp:ExactlyOne>
  <wsp:All>
  <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
   <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">
   <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">
   <wsp:Policy>
   <sp:TransportToken>
    <wsp:Policy>
    <msf:WindowsTransportSecurity xmlns:msf="http://schemas.microsoft.com/ws/2006/05/framing/policy">
     <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> 

 

如何以svcutil生成正确的绑定类型(在完成每个策略语句时有用)的方式在WSDL中正确链接每个策略?

How can I link in the WSDL each policy correctly, in the way svcutil generate the correct binding type useful to accomplish each policy statement?

例如,我尝试没有成功:

For instance, I tried with no success:

 

...

<wsdl:binding name="hcBindingwsHttps_V1" type="tns:hcPortType_V1">
 <wsp:PolicyReference URI="mypolicy.xml#WSHttpsBinding_policy" wsdl:required="true" />
 <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />

...

 

很明显,如果我将所有策略都放在WSDL中,效果很好...

Obviously If i put all the policy inside the WSDL it works fine...

有人可以帮我吗?

Thx

推荐答案

<wsp:PolicyReference xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
         URI="http://localhost:8080/policies.xml#Class1BindingPolicy"/>


这篇关于WSDL-在一个或多个外部xml文件中添加对策略的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 17:48