web services - Implementing WS-I Basic Profile in Spring WS -


my project uses spring ws consume soap webservice. webservice calls sent via webservicetemplate.marshalsendandreceive(..) works fine until now.

recently webservice publisher had informed implement ws-i basic profile 1.1 in order able responses.

following sample received supposedly sent on soap header of request.

<wsse:security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">     <wsse:usernametoken>         <wsse:username> </wsse:username>         <wsse:password type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#passwordtext"> </wsse:password>     </wsse:usernametoken> </wsse:security> 

is there example configure ? how proceed spring-ws security in scenario?

any pointers appreciated.

managed find out myself.

here approach.

  1. declare bean wss4jsecurityinterceptor (this available in spring-ws-security jar) provide credentials via securementusername, securementpassword properties of bean.

also importantly set securementactions 'usernametoken' (which needed , user name , password sent in ws-i basic profile header)

there many other securementaction available securementactions. (please refer http://docs.spring.io/spring-ws/site/reference/html/security.html)

  1. include wss4jsecurityinterceptor bean in webservicetemplate's interceptor property.

  2. voila !

example configuration

<bean id="wssecurityinterceptor"     class="org.springframework.ws.soap.security.wss4j.wss4jsecurityinterceptor">     <property name="securementactions" value="usernametoken" />     <property name="securementusername" value="${security.username}" />     <property name="securementpasswordtype" value="passwordtext" />     <property name="securementpassword" value="${security.password}" />     <property name="securementmustunderstand" value="false" /> </bean>  <bean id="webservicetemplate" class="org.springframework.ws.client.core.webservicetemplate"     p:defaulturi="${service.endpt}" p:marshaller-ref="myservicemarshaller"     p:unmarshaller-ref="myservicemarshaller">     <property name="interceptors">         <list>             <ref local="wssecurityinterceptor" />             ..         </list>     </property> </bean> 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -