【问题标题】:dynamic properties in ws consumer service Addressws消费者服务地址中的动态属性
【发布时间】:2014-06-24 10:24:14
【问题描述】:

我正在使用 Mule 3.5,并且有一个要求,我需要使用一个 SOAP Web 服务,该服务通过 URL 本身的 authority part 完成授权。

我无法控制此 API,因此无法更改它。URL 如下所示

https://2james:Mdops@allscripts/HWS61/ClinicalInfo.svc

其中用户名是 2james,密码是 Mdops。

用户名和密码将传递给 mule 流,之后我需要连接到 SOAP 网络服务。

Mule 文档here,(备忘单部分)解释了如何使用消息属性来自定义 http 出站 url。

<https:outbound-endpoint address="https://#[message.inboundProperties.username]:#[message.inboundProperties.password]@api.acme.com/v1/users" />

我需要与我的 WS 消费者有类似的功能,当我尝试这个 Mule 在启动时失败并抱怨它无法解析 URI 时,我的配置如下所示

<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="Authentication.wsdl" service="Authentication" port="BasicHttpBinding_IAuthentication" serviceAddress="https://2james:Mdops@localhost:443/HWS61/Authentication.svc" doc:name="Web Service Consumer" connector-ref="HTTP_HTTPS">
</ws:consumer-config>

<flow name="testFlow1" doc:name="testFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" mimeType="application/json" contentType="application/json" />

        <ws:consumer config-ref="Web_Service_Consumer" operation="Logon" doc:name="Authentication" />
</flow>

如果我更改 ws:consumer-config 以使用消息属性 Mule 无法启动并出现以下异常

ERROR 2014-06-24 15:53:46,771 [main] org.mule.module.launcher.application.DefaultMuleApplication: null
java.lang.NullPointerException
    at org.mule.endpoint.MuleEndpointURI.getScheme(MuleEndpointURI.java:331)
    at org.mule.module.ws.consumer.WSConsumerConfig.createOutboundEndpoint(WSConsumerConfig.java:50)
    at org.mule.module.ws.consumer.WSConsumer.createMessageProcessor(WSConsumer.java:230)
    at org.mule.module.ws.consumer.WSConsumer.initialise(WSConsumer.java:91)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1612)

**

更新

**

正如下面所回答的,Web 使用者可以使用动态属性,但是当 WS 使用者引用 HTTP 连接器时,问题就出现了。我必须这样做的原因是因为 SOAP WS 依赖于信任库进行身份验证,信任库只能通过 HTTP 连接器进行配置。

所以我更新后的 WS Consumer 看起来像这样。

<ws:consumer-config serviceAddress="https://#[message.payload]:#[message.payload]@localhost:${port}/#[message.inboundProperties['path']]" wsdlLocation="Authentication.wsdl"
                        service="Authentication" port="BasicHttpBinding_IAuthentication" name="Web_Service_Consumer" connector-ref="HTTP_HTTPS"/>


<https:connector name="HTTP_HTTPS" cookieSpec="netscape" validateConnections="true" sendBufferSize="0" receiveBufferSize="0" receiveBacklog="0" clientSoTimeout="10000" serverSoTimeout="10000" socketSoLinger="0" doc:name="HTTP-HTTPS" >
        <https:tls-server path="E:\AppServer\client-truststore.jks" storePassword="welcome" explicitOnly="true" requireClientAuthentication="true" />
    </https:connector>

【问题讨论】:

  • 我已经解决了我的问题。首先从 WS 消费者中删除 HTTP 连接器引用。如果不可接受,则将证书添加到 JDK 信任库中,然后在 ws 消费者之前使用一个组件将信任库详细信息设置为系统属性,WS 消费者将自动使用它。如果有人遇到同样的问题并且无法解决,只需 ping 我。

标签: java web-services soap mule


【解决方案1】:

您可以拥有如下所示的动态地址:https://github.com/mulesoft/mule/blob/c88dbfecc98e5586ee100185082c411ebb0d0f16/modules/ws/src/test/resources/dynamic-address-config.xml

它抱怨它缺少方案,所以你能用动态地址发布 wsconsumer 配置的配置吗?

以下应该有效:

<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="Authentication.wsdl" service="Authentication" port="BasicHttpBinding_IAuthentication" serviceAddress="https://#[message.inboundProperties.username]:#[message.inboundProperties.password]@localhost:443/HWS61/Authentication.svc" doc:name="Web Service Consumer" connector-ref="HTTP_HTTPS">
</ws:consumer-config>

【讨论】:

  • 感谢您的回答,是的,确实如此,我已经进一步更新了我的问题以反映我的确切情况,我忽略了细节,认为这无关紧要
猜你喜欢
  • 2014-02-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-16
  • 2021-11-14
相关资源
最近更新 更多