【问题标题】:Spring Integration outbound-gateway with basic authentication具有基本身份验证的 Spring Integration 出站网关
【发布时间】:2019-01-11 21:06:34
【问题描述】:

我看过一些例子,但我无法使用这些解决方案

问题是我必须将基本身份验证信息作为配置的一部分传递

下面的当前请求...你能告诉我如何添加基本身份验证

<bean id="WSACaoedelen" class="nl.bIntnActiCallback">
        <constructor-arg index="0" value="http://enst.nl/kkm/Kkmervice/toest"></constructor-arg>
        <constructor-arg index="1" value="${KKSEURL}"></constructor-arg>
    </bean> 
    <int:chain input-channel="kkChannel" output-channel="dest-channel">
        <ws:header-enricher>       
            <ws:soap-action value="http://knst.nl/kkm/KkService/toest"/>
        </ws:header-enricher>           
        <ws:outbound-gateway uri="${GATEWAY}" request-callback="WSACaoedelen"/>
    </int:chain>

【问题讨论】:

    标签: spring-integration


    【解决方案1】:

    基本身份验证的意义在于它是 HTTP 传输的一部分。

    您需要考虑使用HttpComponentsMessageSender 和注入的setCredentials()。在你的情况下,我猜你可以使用UsernamePasswordCredentials

    <bean id="httpComponentsMessageSender" class="org.springframework.ws.transport.http.HttpComponentsMessageSender">
        <property name="credentials">
            <bean class="org.apache.http.auth.UsernamePasswordCredentials">
                <constructor-arg value="userName"/>
                <constructor-arg value="password"/>
            </bean>
        </property>
    </bean>
    ...
    <ws:outbound-gateway uri="${GATEWAY}" message-sender="httpComponentsMessageSender"/>
    

    【讨论】:

    • 回答有效。谢谢。由于我们也有加密,我需要使用属性 BSPWD=ENC(${BSPWD}) 和 jasypt beans。
    • 是否可以使用上述启用抢先式身份验证?错误:soapenv:Server.Transport.Http.4011136 HTTP Webservice 返回错误:HTTP/1.1 401 Unauthorized
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-15
    • 1970-01-01
    • 1970-01-01
    • 2022-08-16
    • 1970-01-01
    相关资源
    最近更新 更多