简体   繁体   中英

Apache Camel + Spring-WS + Authorization

I have a project using apache camel, and I have to consume a WS ..

.setHeader(HttpHeaders.AUTHORIZATION, constant("Basic {base64"))
.to("spring-ws:http://myhost.com.br?soapAction=myAction")

And I get the follow error : org.springframework.ws.client.WebServiceTransportException: Unauthorized [401]

If I send using soap-ui just with the header, it's work well.

Any ideas? Thanks a lot.

From http://people.apache.org/~dkulp/camel/spring-web-services.html

A custom message sender or factory in the registry can be referenced like this:

from("direct:example")
.to("spring-ws:http://foo.com/bar?messageFactory=#messageFactory&messageSender=#messageSender")

Spring configuration:

<!-- authenticate using HTTP Basic Authentication -->
<bean id="messageSender" class="org.springframework.ws.transport.http.CommonsHttpMessageSender">
    <property name="credentials">
        <bean class="org.apache.commons.httpclient.UsernamePasswordCredentials">
            <constructor-arg index="0" value="admin"/>
            <constructor-arg index="1" value="secret"/>
        </bean>
    </property>
</bean>

<!-- force use of Sun SAAJ implementation, http://static.springsource.org/spring-ws/sites/1.5/faq.html#saaj-jboss -->
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
    <property name="messageFactory">
        <bean class="com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"></bean>
    </property>
</bean>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM