How to Call a Secure SOAP Service with WS-Security with Apache Axis

import static java.lang.System.out;

import br.eti.fernandoribeiro.wsclient.sample.SamplePortType;
import br.eti.fernandoribeiro.wsclient.sample.SampleRequest;
import br.eti.fernandoribeiro.wsclient.sample.SampleResponse;
import br.eti.fernandoribeiro.wsclient.sample.SampleService;
import br.eti.fernandoribeiro.wsclient.sample.SampleServiceLocator;

public final class Sample {

  public static void main(final String[] args) throws Exception {
    final SampleService service = new SampleServiceLocator();

    final SamplePortType port = service.getSamplePort();

    final SampleResponse res = port.operation(new SampleRequest());




<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="" xmlns:java="">
      <handler type="">
        <parameter name="action" value="UsernameToken" />
        <parameter name="passwordCallbackClass" value="SamplePasswordCallback" />
        <parameter name="passwordType" value="PasswordText" /> <!-- or PasswordDigest -->
        <parameter name="user" value="user" />
  <transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender" />



public final class SamplePasswordCallback implements CallbackHandler {

  public void handle(final Callback[] callbacks) {

    for (int i = 0; i &lt; callbacks.length; i++) {

      if (callbacks[i] instanceof WSPasswordCallback) {
        final WSPasswordCallback cb = (WSPasswordCallback) callbacks[i];





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s