Studio Visual Editor
-
Open the Pattern Properties panel, then click the Security tab.
-
Click the plus sign icon in the Add Configuration Element pane to create a new key-value pair.
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.
-
Enter a key, such as
action
, in the open Key field and press Enter. -
Double-click the new key-value line item you created to open the Add Configuration Property panel.
-
Enter information in either the Value field OR the Value Reference Field according to the table below.
Value
Enter 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 Reference
Enter 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. -
Click Finish to save the key-value pair.
-
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 (i.e. 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">
<flow name="Creation1Flow1" doc:name="Creation1Flow1">
<http:inbound-endpoint host="localhost" port="8081"/>
<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>