gpt4 book ai didi

java - ws 消费者服务地址中的动态属性

转载 作者:行者123 更新时间:2023-11-29 05:21:47 25 4
gpt4 key购买 nike

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

我无法控制此 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 消费者看起来像这样。

<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>

最佳答案

您可以拥有一个动态地址,如下所示: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>

关于java - ws 消费者服务地址中的动态属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24384190/

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