Search code examples
webspherejax-rpc

Adding username token for JAX RPC in websphere application server admin console


I have developed JAX RPC webservice in bottom to top approach. I want to add username token to the webservice from Websphere Application Server admin console.

Usually, RAD (Rational Application Developer) has an option to add username token in Extensions tab, but I developed my webservice in Eclipse. When I opened the wsdl with webservice editor, I didn't find an Extensions tab. So I am trying to add from admin console.Is there any option to add from admin console.


Solution

  • If you are talking about JAX-RPC I assume that you have WAS 6.1. If you don't have RAD, the best option would be to use AST (Application Server Toolkit - eclipse tool provided separately with WAS to assembly and deploy apps).
    For reference you can use this redbook Web Services Handbook for WebSphere Application Server 6.1
    You can edit bindings via console, once you have configuration: Enterprise Applications > JAXRPCEAR > Manage Modules > JAXRPC.war > Web services: Server security bindings, but you will not be able to create configuration there.

    Here are templates for dummy Hello service with username token, you can tweak them to your needs. They might not fully work as I didn't test them. You need to put them in the WEB-INF folder.

    File webservices.xml

    <?xml version="1.0" encoding="UTF-8"?><webservices version="1.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd">
        <webservice-description>
            <webservice-description-name>HelloService</webservice-description-name>
            <wsdl-file>WEB-INF/wsdl/Hello.wsdl</wsdl-file>
            <jaxrpc-mapping-file>WEB-INF/Hello_mapping.xml</jaxrpc-mapping-file>
            <port-component>
                <port-component-name>Hello</port-component-name>
                <wsdl-port xmlns:pfx="http://service">pfx:Hello</wsdl-port>
                <service-endpoint-interface>service.Hello</service-endpoint-interface>
                <service-impl-bean>
                    <servlet-link>service_Hello</servlet-link>
                </service-impl-bean>
            </port-component>
        </webservice-description>
    </webservices>
    

    File ibm-webservices-ext.xmi:

    <?xml version="1.0" encoding="UTF-8"?>
    <com.ibm.etools.webservice.wsext:WsExtension xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:com.ibm.etools.webservice.wsext="http://www.ibm.com/websphere/appserver/schemas/5.0.2/wsext.xmi" xmi:id="WsExtension_1408569011266">
      <wsDescExt xmi:id="WsDescExt_1408569011266" wsDescNameLink="HelloService">
        <pcBinding xmi:id="PcBinding_1408569011266" pcNameLink="Hello">
          <serverServiceConfig xmi:id="ServerServiceConfig_1408569548722">
            <securityRequestConsumerServiceConfig xmi:id="SecurityRequestConsumerServiceConfig_1408569548722">
              <caller xmi:id="Caller_1408569896666" name="basicAuth." part="" uri="" localName="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken"/>
              <requiredSecurityToken xmi:id="RequiredSecurityToken_1408569548722" name="userToken" uri="" localName="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken" usage="Required"/>
            </securityRequestConsumerServiceConfig>
          </serverServiceConfig>
        </pcBinding>
      </wsDescExt>
    </com.ibm.etools.webservice.wsext:WsExtension>
    

    File ibm-webservices-bnd.xmi:

    <?xml version="1.0" encoding="UTF-8"?>
    <com.ibm.etools.webservice.wsbnd:WSBinding xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:com.ibm.etools.webservice.wsbnd="http://www.ibm.com/websphere/appserver/schemas/5.0.2/wsbnd.xmi" xmi:id="WSBinding_1408569011266">
      <wsdescBindings xmi:id="WSDescBinding_1408569011266" wsDescNameLink="HelloService">
        <pcBindings xmi:id="PCBinding_1408569011266" pcNameLink="Hello">
          <securityRequestConsumerBindingConfig xmi:id="SecurityRequestConsumerBindingConfig_1408569960450">
            <tokenConsumer xmi:id="TokenConsumer_1408570879556" classname="com.ibm.wsspi.wssecurity.token.UsernameTokenConsumer" name="usernameTokenConsumer">
              <valueType xmi:id="ValueType_1408570879556" localName="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken" uri="" name="Username Token"/>
              <jAASConfig xmi:id="JAASConfig_1408570879556" configName="system.wssecurity.UsernameToken"/>
              <partReference xmi:id="PartReference_1408570879556" part="userToken"/>
            </tokenConsumer>
          </securityRequestConsumerBindingConfig>
        </pcBindings>
      </wsdescBindings>
    </com.ibm.etools.webservice.wsbnd:WSBinding>