gpt4 book ai didi

web-services - 调用 Web 服务时访问 Weblogic 中受密码保护的 WSDL

转载 作者:太空宇宙 更新时间:2023-11-03 13:43:48 26 4
gpt4 key购买 nike

我们使用 Spring 和 JAXWS 生成的客户端类来访问 weblogic 部署的应用程序中的 web 服务。定义 Web 服务的 WSDL 是远程的并且受密码保护(基本的 http 身份验证)。在单元测试中,只需在 ~/.metro 文件夹中定义一个代理,并在访问它时使用 url 和 http 密码。 Weblogic 在某些配置文件中是否有类似的技巧?还是有其他一些常见的方法可以解决这个问题?

最佳答案

根据文档(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"/>
</bean>

你试过吗?

更新:由于您使用的是 JAX-WS 客户端(这不是我从“我们正​​在使用 Spring”中理解的),您可以:

关于web-services - 调用 Web 服务时访问 Weblogic 中受密码保护的 WSDL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3180411/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com