[jboss-user] [JBoss AS Documentation] - Re: How can I resolve "General web Service security error"?

Fernando Lozano do-not-reply at jboss.com
Thu Nov 22 14:09:17 EST 2012


Fernando Lozano [https://community.jboss.org/people/fsl] created the discussion

"Re: How can I resolve "General web Service security error"?"

To view the discussion, visit: https://community.jboss.org/message/777993#777993

--------------------------------------------------------------
Hi Alessio,

I followed your hints, jboss-ws and cxf docs the best as I coud, and took a look to the testcases your provided the links. Nothing worked. My goal is getting the simpler working consumer for a WS-Security Username Token enabled service.

I'm using jboss as 7.1.1 and eclipse juno SR1 under Fedora 17 and with jboss-tools-4.0.0-beta1 and OpenJDK7.

Started from a working sample internet service, avaibable online as  http://parabank.parasoft.com/parabank/services/store-wss-01?wsdl http://parabank.parasoft.com/parabank/services/store-wss-01?wsdl (info about the sampe at  http://parabank.parasoft.com/parabank/services.htm http://parabank.parasoft.com/parabank/services.htm). 

It looks the WSDL from that service nas no WS-Policy definitions, but I can consume it using SoapUI and setting the request property WSS-Password Type to "PasswordText".

Used Eclipse/JBoss Tools wizzards to create a sample client. The client is a Java SE app, although it is inside a Dynamic Web Project. Added cfx and wss4j jars from jboss to the project classpath, so I can get CXF classes. It doesn't worked with or without the handler.

Here's the code:

package testwsse.bookstore.auth.clientsample;

import java.util.List;

import javax.xml.ws.BindingProvider;
import org.apache.cxf.ws.security.SecurityConstants;

import testwsse.bookstore.auth.*;


public class ClientSample {

    public static void main(String[] args) throws java.lang.Exception {
            System.out.println("***********************");
            System.out.println("Create Web Service Client...");
            Bookstore_Service service1 = new Bookstore_Service();
            System.out.println("Create Web Service...");
            Bookstore port1 = service1.getCartServicePort();

            System.out.println("Configuring WS-Security...");            

            //XXX won't work
            ((BindingProvider)port1).getRequestContext().put(SecurityConstants.USERNAME, "soatest");
            ((BindingProvider)port1).getRequestContext().put(SecurityConstants.PASSWORD, "soatest");

            //XXX won't work either, callback is never called
            //((BindingProvider)port1).getRequestContext().put(SecurityConstants.USERNAME, "soatest");
            //((BindingProvider)port1).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,
            //      "testws.bookstore.auth.clientsample.UsernamePasswordCallback");


            System.out.println("Call Web Service Operation...");

            List<Book> livros = port1.getItemByTitle("Java");
            System.out.println("Found: " + livros.size() + " books.");
            for (Book livro : livros) {
                System.out.println("Book Title: " + livro.getName());
                for (String autor: livro.getAuthors()) {
                    System.out.println("Author: " + autor);
                }
            }

            System.out.println("***********************");
            System.out.println("Call Over!");
    }
}


And here's the result:

***********************
Create Web Service Client...
Create Web Service...
Configuring WS-Security...
Call Web Service Operation...
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: An error was discovered processing the <wsse:Security> header
    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
    at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:111)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:129)
    at $Proxy32.getItemByTitle(Unknown Source)
    at testwsse.bookstore.auth.clientsample.ClientSample.main(ClientSample.java:34)
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/777993#777993]

Start a new discussion in JBoss AS Documentation at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2079]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20121122/d038eee8/attachment.html 


More information about the jboss-user mailing list