Studio Visual Editor
-
Search for "cxf" and drag the CXF (SOAP) building block to the canvas.
-
Click the CXF element to open the properties menu.
-
Click the Security tab.
-
Click the icon in the Add Configuration Element pane to create a new key-value pair.
-
Click cxf:property key and Enter a key, such as
action
, in the Key field and press Enter:In XML, this step mirrors the addition of a key-value pair inside the ws-config child element of a ws-security element. By adding configuration elements to your SOAP component, you are creating a map of key-value pairs that correspond to the CXF WSS4J security-configuration text strings in WSHandlerConstants and WSConstants.
-
Click the Value field and specify a WS Constant (a class to define the kind of access the server allows) or a WSHandlerConstant (a class to specify the names, actions, and other strings for data deployment of the WSS handler). For example, enter
UsernameToken
in the value field. -
Open the Value Reference field and specify the bean that the key must reference. When the key must reference a bean (for instance, when the key is
passwordCallbackRef
), enter the name of the bean in the Value Reference field. -
Repeat the steps above to add as many ws-security configurations as you wish to your Web service, then click OK to save your configurations.
Studio XML Editor or Standalone
-
To your CXF element (that is, a SOAP component), add a child element for
cxf:ws-security
. -
Within the
cxf:ws-security
child element, add a child element forcxf:ws-config
. -
Within the
cxf:ws-config
child element, add a child element forcxf:property
. -
Add two attributes to the cxf:property child element according to the table below. Be sure to enter either a
value`OR a `value-ref
; the two are mutually exclusive.key
Specify a name for the property.
value
Specify a WS Constant (a class to define the kind of access the server allows) or a WSHandlerConstant (a class to specify the names, actions, and other strings for data deployment of the WSS handler). For example, enter
UsernameToken
in the value field.value- ref
Specify the bean that the key must reference. When the key must reference a bean (for instance, when the key is
passwordCallbackRef
), specify the name of the bean as the value-ref. -
Repeat the preceding step to add as many WS-security configurations as you wish to your Web service. Refer to sample code below.
View the Namespace
<mule xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
...
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd">
<http:listener-config name="listener-config" host="localhost" port="8081"/>
<flow name="Creation1Flow1" doc:name="Creation1Flow1">
<http:listener config-ref="listener-config" path="/" doc:name="HTTP Connector"/>
<cxf:jaxws-service doc:name="SOAP">
<cxf:ws-security>
<cxf:ws-config>
<cxf:property key="action" value="UsernameToken"/>
</cxf:ws-config>
</cxf:ws-security>
</cxf:jaxws-service>
</flow>