[jboss-user] [JBossWS] - UsernameToken authentication using JBossWS

leandroal do-not-reply at jboss.com
Thu Dec 6 18:16:08 EST 2007

Hi folks,

 I need to consume a certain webservice that use a UsernameToken
authentication method. Using SOAPui it generate the following SOAP


I use the wsconsumer.sh and jboss generated all the java classes
necessary to have the objects, and I have the following code:

(... some imports ...)

@WebServiceClient(name = "Vaisala", targetNamespace = "http://www.xxx.com/",
                wsdlLocation = "http://xxx/WebS/xxx.asmx?WSDL")
public class MyInfoBean implements InfoIF {

       public MyInfoBean() {


       public String makeRequest(int arg0) {
               Service service = null;

       try {
           URL wsdlLocation = new URL("http://xxx/WebS/xxx.asmx?WSDL");
           QName serviceName = new QName("http://www.xxx.com/", "TheService");
           service = Service.create(wsdlLocation, serviceName);
       catch(Exception e)

       ServiceSOAP serviceSoap = service.getPort(ServiceSOAP.class);

       URL url = null;
               try {
                       url = new File("/home/leandro/jboss-wsse-client.xml").toURL();
               } catch (MalformedURLException e) {

       ((StubExt)serviceSoap).setConfigName("Standard WSSecurity Client");

       UsernameToken usernameToken = new UsernameToken();

       // I NEED TO PASS THE UsernameToken information to be inserted
into the SOAP-Header of the SOAP envelop, how to do this?

       String stations = serviceSoap.getName();

       return "";


My jboss-wsse-client.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-ws-security xmlns="http://www.jboss.com/ws-security/config" 
                   xsi:schemaLocation="http://www.jboss.com/ws-security/config http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">

By the way, I'm getting HTTP 404 Error when I try to access http://www.jboss.com/ws-security/config.

I can't call serviceSoap.getName() because I don't know how to pass
the UsernameToken object. Anyone to help me?

Thank you,

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4111042#4111042

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4111042

More information about the jboss-user mailing list