views:

40

answers:

1

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?

A: 

According 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 WebServiceMessageSender interface for sending messages via HTTP. The default implementation is the HttpUrlConnectionMessageSender, which uses the facilities provided by Java itself. The alternative is the CommonsHttpMessageSender, 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"/&gt;
</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:

Pascal Thivent
Looks good but I'm using org.apache.cxf.jaxws.JaxWsProxyFactoryBean as the web service client bean, not Spring web service templates (failed to get them to work with Weblogic 9.2 and jaxws-generated client stubs/classes).Is there any way to combine the two?
michuk
@michuk: Erf, you should mention this kind of details in your question to get better answers. This would also help reader to not waste their time.
Pascal Thivent
@Pascal sorry for that, I wrote that we use JAXB client classes. I edited my question now to explicitly state we're using jaxws stubs as well. I've been fighting with the jaxws configuration for some time now, including the conduit element. I'll report back when I manage to achieve something.
michuk
@michuk: I was really wondering if that JAXB stuff was a typo. No problem anyway, I actually didn't waste that much time (especially since I learned something new about Spring) but could have ;)
Pascal Thivent
Unfortunately I failed to make it work in Weblogic 9.2. I'm getting a different exception when using the user/password than when not using it (404 versus html with a permission error message) but I can access that web service from firefox with no problems so it indicates the issue is somewhere between spring/jaxb and weblogic...
michuk