[JBossWS] - How to use Username Token
by Dark Fett
Hello,
I'm trying to use Username Token but it's not successful for now. The Username Token is not present in the Header of my request. (Signature and Encryption work fine in both side)
Here's my code :
jboss-wsse-client.xml
<?xml version="1.0" encoding="UTF-8"?>
| <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">
|
| <key-store-file>service.jks</key-store-file>
| <key-store-password>apache</key-store-password>
|
| <trust-store-file>client.jks</trust-store-file>
| <trust-store-password>apache</trust-store-password>
| <config>
| <username/>
| <sign type="x509v3" alias="service"/>
| <requires>
| <signature/>
| </requires>
| </config>
| </jboss-ws-security>
That's part seems to be good. But I don't know how to insert my own username and my password in MyCall.java.
MyCall.java
| Service service = Service.create(
| new URL("http://proxiadev34:8080/SampleJBossWS/PersonneWebService?wsdl"),
| new QName("PersonneWebServiceService")
| );
|
| URL securityURL = new File("jboss-wsse-client.xml").toURL();
| ((ServiceExt)service).setSecurityConfig(securityURL.toExternalForm());
|
|
| PersonneWebService personneWS = service.getPort(PersonneWebService.class);
| ((StubExt)personneWS).setConfigName("Standard WSSecurity Client");
|
| //Appel de la Fonction getNomVille(Long codePostal)
| String ville = personneWS.getNomVille(59000);
| System.out.println(ville);
For the server, I found the way to get the Username Token from the Request
String username = SecurityAssociation.getPrincipal().getName();
| String password = SecurityAssociation.getCredential().toString();
|
| System.out.println(username);
| System.out.println(password);
If anybody have an idea in order to put the username and the password, it would be welcome.
Thank you for nay help.
Dark Fett
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4040908#4040908
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4040908
17 years, 8 months
[JBossWS] - InvalidClassException running a webservice client
by jaap.taal
I'm trying to run a webservice client as described by the jbossws-userguide.pdf that goes with jbossws-1.0.4GA. I'm using jboss-4.0.5GA
The client should connect to a JSR181 webservice. I use a J2EE application jar that should allow me to use JNDI to access the webapplication from my simple client.
I get the following exception:
| [java] 02:46:33,062 ERROR [ServiceObjectFactory] Cannot create service
| [java] javax.naming.NamingException: Cannot unmarshall service ref meta data, cause: java.io.InvalidClassException: javax.xml.namespace.QName; local class incompatible: stream classdesc serialVersionUID = 4418622981026545151, local class serialVersionUID = -9120448754896609940
| [java] at org.jboss.ws.jaxrpc.ServiceObjectFactory.getObjectInstance(ServiceObjectFactory.java:126)
| [java] at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
| [java] at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1125)
| [java] at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1142)
| [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:705)
| [java] at org.jboss.naming.client.java.javaURLContextFactory$EncContextProxy.invoke(javaURLContextFactory.java:135)
| [java] at $Proxy0.lookup(Unknown Source)
| [java] at javax.naming.InitialContext.lookup(Unknown Source)
| [java] at Main.main(Unknown Source)
|
The source code of the client:
| InitialContext iniCtx0 = new InitialContext();
| Hashtable env = iniCtx0.getEnvironment();
| env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
| env.put("j2ee.clientName", "jbossws-client");
| System.out.println(env);
| InitialContext iniCtx = new InitialContext(env);
|
| MyFirstService service = (MyFirstService) iniCtx
| .lookup("java:comp/env/service/MyFirstService");
| HelloIF port = service.getHelloIFPort();
| System.out.println(port.sayHello());
|
I don't know what I'm doing wrong.
Everything runs from ant scripts which are executed by Eclipse.
Any help would be much apreciated
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4040800#4040800
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4040800
17 years, 8 months