1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| package tutorial.rampart.client;
import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
public class SecureServiceCGClient {
// -uri http://localhost:8080/axis2/services/SecureService?wsdl -p tutorial.rampart.client -uw
public static void main(String[] args) throws Exception {
System.setProperty("javax.net.ssl.trustStore", "keys/server.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "password");
//To be able to load the client configuration from axis2.xml
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("client-repo", null);
SecureServiceStub stub = new SecureServiceStub(ctx,"https://localhost:8080/axis2/services/SecureService");
ServiceClient sc = stub._getServiceClient();
sc.engageModule("rampart");
Options options = sc.getOptions();
options.setUserName("apache");
options.setPassword("password");
int a = 3;
int b = 4;
int result = stub.add(a, b);
System.out.println(a + " + " + b + " = " + result);
}
} |
Partager