Hiya,

I do something like this to get it working - this is for client + server
side certificates, for server certs only you should remove the lines
referring to keystores and keep the ones with truststores (assuming you're
using a self signed cert).

public static final String SERVICE_NAMESPACE =
"http://ws.blah.foo.com/Messaging";;
    public static final String SERVICE_URL =
"https://gbws-00054766/services/MessagingService";;

    public static void main(String[] args) throws Exception {
        System.setProperty("javax.net.ssl.keyStore",
"c:/projects/steve/idea/xfire/test/client.p12");
        System.setProperty("javax.net.ssl.keyStoreType","PKCS12");
        System.setProperty("javax.net.ssl.keyStorePassword", "password");
        System.setProperty("javax.net.ssl.trustStore",
"c:/projects/steve/idea/xfire/test/client.truststore");
        
System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
        Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

        new Test().execute();
    }

    public void execute() throws MalformedURLException, IOException {
        Service serviceModel = new
ObjectServiceFactory().create(Messaging.class, "MessagingService",
SERVICE_NAMESPACE, null);
        Messaging service = (Messaging)new
XFireProxyFactory().create(serviceModel, SERVICE_URL);

        long then = System.currentTimeMillis();

        service.sendChannelMessage("botdev", "Bots", "Test message to
channel, no file, no alert", false);

        long now = System.currentTimeMillis();
        System.out.println("Took " + (now - then) + "ms");
    }

Job's a good un...

steve

> How to get a client connected through ssl?
>
> /*********
> String serviceUrl = "https://localhost:8443/CVSA-xfire-1.0/EchoService";;
>         Echo client = null;
>         try {
>                       client = (Echo) factory.create(serviceModel,
> serviceUrl);
>                       Client cli = ((XFireProxy)
> Proxy.getInvocationHandler(client)).getClient();
>
> cli.setProperty(CommonsHttpMessageSender.HTTP_PROXY_PORT, "8080");
>                       cli.setProperty(Channel.USERNAME, "xxx");
>                       cli.setProperty(Channel.PASSWORD, "mypass");
>
>
>
> Thx in advance. Xris.
>
>


-- 
Steve Barham                       tel: +44 (0)7973 199 471
Systems Engineer
Formicary - delivering quality financial technology solutions
http://www.formicary.net/

Reply via email to