我已经在WSO2 EI上配置了WSDL代理服务,该服务指向由OAuth保护的外部服务。
我的问题是,除了我所有的努力之外,我无法在服务调用上设置Bearer Authorization标头。服务端点始终返回“找不到oauth令牌”错误。我已经尝试了所有有关标题的WSO2教程和文档(使用Header Mediator和header作为属性),但是没有任何效果。
我的问题类似于this one,也没有答案。
WSDL代理服务由WCF .NET应用程序使用,并且设置了Bearer标头。
这是XML配置:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="WSDLProxy"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http">
<target>
<inSequence>
<send>
<endpoint>
<wsdl port="RegisterEndpoint"
service="RegisterService.serviceagent"
uri="[external-wsdl-uri]"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<publishWSDL uri="[external-wsdl-uri]"/>
</proxy>
答案 0 :(得分:0)
在直通场景中,例如WSDL代理服务的给定示例,如果“授权”标头是在客户端对“ WSDLProxy”的请求中发送的,则它将被发送到后端服务。但是,如果客户端在自定义传输头中发送Bearer令牌,则必须在后端调用之前将其设置为“ Authorization”头,如下所示。
...
<inSequence>
<property expression="get-property('transport', 'CUSTOM-Bearer')" name="Authorization" scope="transport" type="STRING"/>
<property action="remove" name="CUSTOM-Bearer" scope="transport"/>
<send>
<endpoint>
<wsdl port="RegisterEndpoint"
service="RegisterService.serviceagent"
uri="[external-wsdl-uri]"/>
</endpoint>
</send>
</inSequence>
...