1

wdsl我已经通过 Https 从服务于我必须使用的 Web 服务的 Soap 服务器检索了一个文件。然后,我使用 Apache Cxfwsdl2java创建了客户端存根,以便检查与 Web 服务服务器的通信。

我知道远程服务器受密码保护(并使用 https 保护),因此,正如预期的那样,远程服务器HTTP error 401在我启动存根时返回。好的,我需要进行身份验证。

在 Apache CXF 文档中,他们首先介绍了Basic Authentication,它看起来像:

 <conduit name="{http://example.com/}HelloWorldServicePort.http-conduit"
   xmlns:sec="http://cxf.apache.org/configuration/security"
   xmlns="http://cxf.apache.org/transports/http/configuration">
   <authorization>
      <sec:UserName>myuser</sec:UserName>
      <sec:Password>mypasswd</sec:Password>
      <sec:AuthorizationType>Basic</sec:AuthorizationType>
   </authorization>
 </conduit>

但是,CXF 生成的代码不包含任何配置 xml 文件。所以我想知道我在哪里放置这个 xml 配置以进行身份​​验证?

我想知道{http://example.com/}HelloWorldServicePort.http-conduit对应的是什么?

4

1 回答 1

2

如果您不想使用配置文件,可以通过编程方式配置管道。创建一个AuthorizationPolicy,并使用HTTPConduit.setAuthorization在管道上设置它。否则,您将要使用 Spring来配置客户端。

于 2013-02-27T02:34:06.907 回答