Hi!
Ok.. now actually I'm about getting crazy!! :)
PeterJ, which is that location? I don't mind if it's not free... I have tried to
send you a "PM" but it seems it doesn't work...
My problem is implementing the client in Java.. I think I have all the files I have to
package.
I'm gonna explain all the things I've done with the client
Hello.java
| package wssec;
|
| import javax.jws.WebMethod;
| import javax.jws.WebParam;
| import javax.jws.WebService;
| import javax.jws.soap.SOAPBinding;
|
| import org.jboss.ws.annotation.EndpointConfig;
|
| @WebService(name = "Hello", targetNamespace = "urn:ws.sec")
| @EndpointConfig(configName = "Standard WSSecurity Endpoint")
| @SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
| public class Hello
| {
| @WebMethod
| public String echo(@WebParam(name = "nombre") String nombre)
| {
| return nombre;
| }
| }
HelloClient.java
| package wssec;
|
| import java.io.File;
| import java.net.URL;
| import java.util.Map;
|
| import javax.xml.namespace.QName;
| import javax.xml.ws.BindingProvider;
| import javax.xml.ws.Service;
|
| import org.jboss.ws.core.StubExt;
|
| public class HelloClient
| {
| public static void main(String args[])
| {
| if (args.length != 1)
| {
| System.err.println("usage: HelloClient <message>");
| System.exit(1);
| }
|
| System.setProperty("org.jboss.wsse.keyStore",
"c:/keys/wsse.keystore");
| System.setProperty("org.jboss.wsse.keyStorePassword",
"jbossws");
| System.setProperty("org.jboss.wsse.keyStoreType", "x509v3");
| System.setProperty("org.jboss.wsse.trustStore",
"c:/keys/wsse.truststore");
| System.setProperty("org.jboss.wsse.trustStorePassword",
"jbossws");
| System.setProperty("org.jboss.wsse.trustStoreType", "x509v3");
|
| try{
| Hello hello = getPort();
| System.out.println("Server said: " + hello.echo(args[0]));
| } catch (Exception e){
| e.printStackTrace();
| }
| }
|
| private static Hello getPort() throws Exception
| {
| URL wsdlURL = new URL("http://127.0.0.1:8080/Hello/Hello?wsdl");
| URL securityURL = new File("META-INF/jboss-wsse-client.xml").toURL();
| QName serviceName = new QName("urn:ws.sec",
"HelloService");
|
| Service service = Service.create(wsdlURL, serviceName);
|
| Hello port = (Hello)service.getPort(Hello.class);
| ((StubExt)port).setSecurityConfig(securityURL.toExternalForm());
| ((StubExt)port).setConfigName("Standard WSSecurity Client");
|
| Map<String, Object> reqContext =
((BindingProvider)port).getRequestContext();
| reqContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://127.0.0.1:8080/Hello");
|
| return port;
| }
|
| }
|
jboss-wsse-client.xml
| <?xml version="1.0" encoding="ISO-8859-1"?>
| <jboss-ws-security
xmlns="http://www.jboss.com/ws-security/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/ws-security/config
http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">
| <config>
| <sign type="x509v3" alias="wsse"/>
| <requires>
| <signature/>
| </requires>
| </config>
| </jboss-ws-security>
|
The keystore and the truststore are the same as the server's ones.
The structure is
wssec
| Hello.class
| HelloClient.class
META-INF
| wsse.keystore
| wsse.truststore
| jboss-wsse-client.xml
When I run the client, I do it like this:
| wsrunclient prueba.HelloClient "Hello"
|
What am I missing? Shall I do anything more? Or maybe less? :)
Thanks a lot.. ;)
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4121248#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...