java - dynamic properties in ws consumer service Address -



java - dynamic properties in ws consumer service Address -

i using mule 3.5 , have requirement need consume soap webservice authorization done via authority part of url itself.

i not have command on api , hence cannot alter it.the url below

https://2james:mdops@allscripts/hws61/clinicalinfo.svc

where username 2james , password mdops.

the username , password passed on mule flow after need connect soap webservice.

mule documentation here, (cheat sheet section) explains how message properties can used customise http outbound url.

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

i need have similar functionality ws consumer, when seek mule fails on startup complaining cannot parse uri, configuration looks below

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

if alter ws:consumer-config utilize message properties mule fails start below exception

error 2014-06-24 15:53:46,771 [main] org.mule.module.launcher.application.defaultmuleapplication: null java.lang.nullpointerexception @ org.mule.endpoint.muleendpointuri.getscheme(muleendpointuri.java:331) @ org.mule.module.ws.consumer.wsconsumerconfig.createoutboundendpoint(wsconsumerconfig.java:50) @ org.mule.module.ws.consumer.wsconsumer.createmessageprocessor(wsconsumer.java:230) @ org.mule.module.ws.consumer.wsconsumer.initialise(wsconsumer.java:91) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokecustominitmethod(abstractautowirecapablebeanfactory.java:1612)

**

update

**

as answered below web consumer can work dynamic properties, problem comes in when ws consumer refers http connector. reason had because soap ws depends on truststore authentication, trust store can configured via http connector.

so updated ws consumer looks this.

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

you can have dynamic address shown here: https://github.com/mulesoft/mule/blob/c88dbfecc98e5586ee100185082c411ebb0d0f16/modules/ws/src/test/resources/dynamic-address-config.xml

its complaining missing scheme, post config wsconsumer config dynamic address?

the next should work:

<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 web-services soap mule

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -