We're using Spring and JAXWS-generated client classes to access web services in a weblogic-deployed app. The WSDL defining the web service is remote and password-protected (basic http authentication). In a unit test it suffices to define a proxy in ~/.metro folder with the url and http password to use when accessing it. Is there a similar trick for Weblogic in some configuration file? Or is there some other common way of solvind this issue?
views:
40answers:
1According to the documentation (Chapter 6. Using Spring Web Services on the Client):
6.2.1.1.1. HTTP transports
There are two implementations of the
WebServiceMessageSenderinterface for sending messages via HTTP. The default implementation is theHttpUrlConnectionMessageSender, which uses the facilities provided by Java itself. The alternative is theCommonsHttpMessageSender, which uses the Jakarta Commons HttpClient. Use the latter if you need more advanced and easy-to-use functionality (such as authentication, HTTP connection pooling, and so forth).(...)
The folowing example shows how override the default configuration, and to use Commons Http to authenticate using HTTP authentication:
<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"> <constructor-arg ref="messageFactory"/> <property name="messageSender"> <bean class="org.springframework.ws.transport.http.CommonsHttpMessageSender"> <property name="credentials"> <bean class="org.apache.commons.httpclient.UsernamePasswordCredentials"> <constructor-arg value="john"/> <constructor-arg value="secret"/> </bean> </property> </bean> </property> <property name="defaultUri" value="http://example.com/WebService"/> </bean>
Did you try this?
Update: Since you're using a JAX-WS client (which is not what I understood from "we're using Spring"), you can either:
- Set a default
Authenticatoras described in HTTP basic authentication with JAX-WS (Client). - Use Spring and configure a
http-conf:authorizationfor theconduitelement. See Client HTTP Transport (including SSL support).