简体   繁体   中英

WebService Client creation using Apache Axis2 and Rampart

We have a requirement where a webservice with username token security has been created in IBM Websphere Integration Developer 6.1. Now, in order to test this, we have to develop a Web Service Client in Java. The requirement is to get this done using Apache Axis2. After doing a lot of reading on this, I was able to use Axis2 to generate a client for a simple Web Service which does not require authentication and I was able to test it correctly. But I came to know that in order to use UserName token Security with axis2, rampart is needed.

Now I need to know how to use Rampart with Axis2 in eclipse. We dont have apache server installed in our systems, but we deploy it in eclipse. Even after reading a lot of articles on the same, I havent been able to get Rampart to work.

Can someone please guide me through the steps of configuring Rampart in eclipse and also how to use it for WebService Client Generation using UserName token?

So far, using Axis2 I used to do the following Steps. 1. Create a Java Project and import the required WSDLs into it. 2. Using the WSDLs, I create the WebServiceClient and the following types of files get generated a. A java Interface file b. A Java Proxy file which implements the interface mentioned in ac A java stub file which extends org.apache.axis.client.Stub and implements the interface mentioned in ad A java Service file which is again an interface e. A java ServiceLocator file which implements the above interface.

So, I also need to know how I can use these files for testing the Username Token Web Service.

When I do the above using a Dynamic Web project and right click on the WSDLs and click on generate client, a ServiceCallBackHandler.java and HttpSrviceStub files are created. How do i use these to achieve the testing?

Thanks.

I haven't used rampart for Username Tokens, but for my services (signing and encrypting) IBM documentation was really helpful. Have a look at: http://www.ibm.com/developerworks/java/library/j-jws4/ Java Web services: Axis2 WS-Security basics; See how to install Rampart into Axis2 and implement UsernameToken handling

For my project Java source is the same when I use WS-Security (working environment) and without WS-Security (test environment). All I have to do on client side it to enable/disable rampart configuration from my_client/axis-repo/conf/axis2.xml . Have a look at: http://wso2.org/library/240 where you will find example configuration that may be useful to you:

<parameter name="OutflowSecurity">
        <action>
                <items>UsernameToken</items>
                <user>bob</user>
                <passwordCallbackClass>org.apache.rampart.
                samples.sample02.PWCBHandler</passwordCallbackClass>
        </action>
</parameter>

first of all u have to load rampart modules files in axis2 modules files. Then load the library required for rampart in lib folder. and then use a callback handler class in which u have define the logic for user name and password. All the above things in vailable in ramart source code and rampart folder.u have to download it from rampart web site After then in axis2.xml u have to define tag

<parameter name="InflowSecurity">
  <action>
    <items>UsernameToken</items>
    <user>jaideep</user>
    <passwordCallbackClass>com.mltvacations.externalapi.callbackhandler.PasswordCallbackHandler</passwordCallbackClass>
    <passwordType>PasswordText</passwordType>


  </action>
</parameter> 

with in tag. then run the web service and copy the address of wsdl and put into soapUi and then add the authentication header. and check it.

If any problem then tell me.I will give u satisfactory answer beacuse i have used the rampart security.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM