如何在我尝试为 SOAP Web 服务创建的文档中wsdl
添加安全策略wsp:Policy
?
<wsp:Policy wsu:Id="UserNameWSTrustBinding_IWSTrust13Async_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>...</wsp:Policy>
</sp:TransportBinding>
<sp:SignedEncryptedSupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>...</wsp:Policy>
</sp:SignedEncryptedSupportingTokens>
<sp:EndorsingSupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>...</wsp:Policy>
</sp:EndorsingSupportingTokens>
<sp:Wss11 xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">...</sp:Wss11>
<sp:Trust13 xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">...</sp:Trust13>
<wsaw:UsingAddressing/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
我正在使用JAX-WS和Spring来构建SOAP Web服务。服务的一部分也是提供元数据,这主要是我通过使用 API 编写 WSDL 定义来构建WSDL4J
元数据。如下所示:
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
Definition definition = wsdlFactory.newDefinition();
// Namespaces
setNamespaces(definition);
// Policy
setPolicy(definition);
// Messages - Input
setInputMessageForWSDLDefinition(definition);
// Messages - Output
setOutputMessageForWSDLDefinition(definition);
// PortType
setPortTypeForWSDLDefinition(definition);
// Binding
setBindingForWSDLDefinition(definition);
// Service
setServiceForWSDLDefinition(definition, singleSignOnService);
这就是我向 wsdl 添加策略的方式
@Policies(
{ @Policy(uri = "classpath:SecurityPolicy.xml") })
apache-cxf
提供了向 WSDL 添加策略的此工具