Man*_*ath 5 soap web-services jax-ws apache-camel webservices-client
我有 SOAP Web 服务的 WSDL 文件,我需要通过 http 调用它。使用 cxf wsdl2java 插件我创建了存根方法。
我已经使用 jaxws 创建了 Web 服务客户端。Web 服务启用了基本身份验证。我正在尝试配置 http 管道
my application.properties
--------------------------
webservices.http.auth.username=username
webservices.http.auth.password=password
fold.webservices.http.auth.authtype=Basic
webservices.http.conduit.property.name=https://fixed_deposits-test.co.in/fold-webservices/services.*
fold.updateservice.soap.address=https://fixed_deposits-test.co.in/fold-webservices/services/UpdateService
----------------------------
Run Code Online (Sandbox Code Playgroud)
我的春天背景...
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xmlns:sec="http://cxf.apache.org/configuration/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="properties" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
<property name="locations">
<util:list>
<value>file:${config.dir}/application.properties</value>
</util:list>
</property>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
</bean>
<jaxws:client id="updateServiceClient" serviceClass="com.fold.facade.v1.UpdateService" address="${fold.updateservice.soap.address}" >
<jaxws:inInterceptors>
<bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor" >
<property name="prettyLogging" value="true" />
</bean>
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" >
<property name="prettyLogging" value="true" />
</bean>
</jaxws:outInterceptors>
</jaxws:client>
<http-conf:conduit name="***?????????***">
<http-conf:authorization>
<sec:UserName>${fold.webservices.http.auth.username}</sec:UserName>
<sec:Password>${fold.webservices.http.auth.password}</sec:Password>
<sec:AuthorizationType>${fold.webservices.http.auth.authtype}</sec:AuthorizationType>
</http-conf:authorization>
</http-conf:conduit>
Run Code Online (Sandbox Code Playgroud)
我在网上进行了大量搜索,以便了解name 属性的有效值应该是什么。
根据 CXF 文档,它应该是......
{WSDL_endpoint_target_namespace}PortName.http-conduit
Run Code Online (Sandbox Code Playgroud)
我的 WSDL 文件有..
...
targetNamespace="http://facade.fold.com/" and
...
<wsdl:port binding="tns:UpdateServiceImplServiceSoapBinding"
name="UpdateServiceImplPort">
<soap:address
location="https://fixed_deposits-test.co.in/fold-webservices/services/UpdateService" />
</wsdl:port>
Run Code Online (Sandbox Code Playgroud)
所以我尝试了这些..
<http-conf:conduit name="{http://facade.fold.com/}UpdateServiceImplPort.http_conduit">
or
<http-conf:conduit name="*UpdateServiceImplPort.http_conduit">
or
<http-conf:conduit name="{http://facade.fold.com/}*.http_conduit">
Run Code Online (Sandbox Code Playgroud)
但当我收到 401 未经授权的异常时,它们都不起作用。
org.apache.cxf.transport.http.HTTPException:与https://fixed_deposits-test.co.in/fold-webservices/services/UpdateService通信时出现 HTTP 响应“401:未经授权”
我有几种让它发挥作用的方法
a) <http-conf:conduit name="*.http_conduit">
Run Code Online (Sandbox Code Playgroud)
但我真的不想这样做......
b) <http-conf:conduit name="https://fixed_deposits-test.co.in/fold-webservices/services/UpdateService">
Run Code Online (Sandbox Code Playgroud)
这是对 SOAP 服务 URL 进行硬编码...我不希望这样做,因为我正在寻找外部化 URL,因为我的 SOAP URL 对于不同的环境是不同的..(dev /test /prod 等)
下面是我在外部化方面的最佳尝试,但它因 401 Unauthorized Exception 而失败......
在我的 spring 上下文中的所有其他实例中,属性都被替换,但 http-conf:conduit name 属性没有被替换:(
<http-conf:conduit name="${webservices.http.conduit.property.name}">
Run Code Online (Sandbox Code Playgroud)
作为一种解决方法,我目前正在使用有效的正则表达式方法。
<http-conf:conduit name="*.*/fold-webservices/services/UpdateService">
Run Code Online (Sandbox Code Playgroud)
但我真的想弄清楚是否可以将其外部化并从属性文件中读取。我想用 Spring 配置方式来做到这一点。请帮我 !!!
小智 2
我有同样的问题...
就我而言,以下两项更改有所帮助:
1)将“Port”后缀添加到端口名称中,尽管它没有在 wsdl 中定义
e.g wsdl:
<wsdl:port name="XXXSoap">
Run Code Online (Sandbox Code Playgroud)
将是管道定义中的“XXXSoapPort”
2)删除目标命名空间名称末尾的“\”
==> 因此尝试
<http-conf:conduit name="{http://facade.fold.com}UpdateServiceImplPort.http_conduit">
or
<http-conf:conduit name="{http://facade.fold.com}UpdateServiceImplPortPort.http_conduit">
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6459 次 |
最近记录: |