You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Vedha Vijayan <vv...@comergent.com> on 2006/12/14 23:47:44 UTC

Axis2 dynamic usertoken configuration problem

I'm working with rampart samples to better understand dynamic
configuration of usernameToken context. I'm trying to do the following;

 ConfigurationContext ctx =
ConfigurationContextFactory.createConfigurationContextFromFileSystem(args[1], args[1] + "/conf/axis2.xml");
        
        ServiceClient client = new ServiceClient(ctx, null);

        //programmatically enable "rampart" module
        client.engageModule( new javax.xml.namespace.QName("rampart"));

        Options options = new Options();        
   
        options.setAction("urn:echo");
        options.setTo(new EndpointReference(args[0]));
   
        //set user context
   
        OutflowConfiguration ofc = new OutflowConfiguration();

        try {
            ofc.setActionItems("UsernameToken");
            ofc.setUser("bob1");

ofc.setPasswordCallbackClass("org.apache.rampart.samples.sample03.PWCBHandler");
            ofc.setPasswordType("PasswordText");
            
            options.setProperty(  WSSHandlerConstants.OUTFLOW_SECURITY,
ofc.getProperty());

            client.setOptions(options);
        
            OMElement response = client.sendReceive(getPayload("Hello
world"));
        
            System.out.println(response);

        }
        catch(Throwable t) {
            t.printStackTrace();
        }


When i execute the client, I get the following error message:

java.lang.ClassCastException:
org.apache.axiom.om.impl.llom.OMElementImpl
     [java]     at
org.apache.axiom.soap.impl.llom.SOAPFaultImpl.getCode(SOAPFaultImpl.java:101)
     [java]     at
org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:308)
     [java]     at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:579)
     [java]     at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508)
     [java]     at
org.apache.rampart.samples.sample03.DynamicUTClient.main(Unknown Source)




The sample code works when I configure the usernameToken from within the
client's axis2.xml file. However, when i try to set it programmatically,
I end up with this error message. I have included rampart's jar as part
of my client classpath. Can anyone please let me know how to resolve
this.

Thanks,
vedha




-- 
Vedha Vijayan
Senior Software Engineer
Comergent Technologies Inc.
Ph:  650 232 5833
Fax: 650 232 6010
Email: vvijayan@comergent.com

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis2 dynamic usertoken configuration problem

Posted by Ruchith Fernando <ru...@gmail.com>.
Hi,

This is a known issue [1] that occurs when a client receives a SOAP 11 fault.

If possible please try using SOAP 12 :

options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);

Thanks,
Ruchith

[1] https://issues.apache.org/jira/browse/AXIS2-1643

On 12/15/06, Vedha Vijayan <vv...@comergent.com> wrote:
> I'm working with rampart samples to better understand dynamic
> configuration of usernameToken context. I'm trying to do the following;
>
>  ConfigurationContext ctx =
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(args[1], args[1] + "/conf/axis2.xml");
>
>         ServiceClient client = new ServiceClient(ctx, null);
>
>         //programmatically enable "rampart" module
>         client.engageModule( new javax.xml.namespace.QName("rampart"));
>
>         Options options = new Options();
>
>         options.setAction("urn:echo");
>         options.setTo(new EndpointReference(args[0]));
>
>         //set user context
>
>         OutflowConfiguration ofc = new OutflowConfiguration();
>
>         try {
>             ofc.setActionItems("UsernameToken");
>             ofc.setUser("bob1");
>
> ofc.setPasswordCallbackClass("org.apache.rampart.samples.sample03.PWCBHandler");
>             ofc.setPasswordType("PasswordText");
>
>             options.setProperty(  WSSHandlerConstants.OUTFLOW_SECURITY,
> ofc.getProperty());
>
>             client.setOptions(options);
>
>             OMElement response = client.sendReceive(getPayload("Hello
> world"));
>
>             System.out.println(response);
>
>         }
>         catch(Throwable t) {
>             t.printStackTrace();
>         }
>
>
> When i execute the client, I get the following error message:
>
> java.lang.ClassCastException:
> org.apache.axiom.om.impl.llom.OMElementImpl
>      [java]     at
> org.apache.axiom.soap.impl.llom.SOAPFaultImpl.getCode(SOAPFaultImpl.java:101)
>      [java]     at
> org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:308)
>      [java]     at
> org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:579)
>      [java]     at
> org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508)
>      [java]     at
> org.apache.rampart.samples.sample03.DynamicUTClient.main(Unknown Source)
>
>
>
>
> The sample code works when I configure the usernameToken from within the
> client's axis2.xml file. However, when i try to set it programmatically,
> I end up with this error message. I have included rampart's jar as part
> of my client classpath. Can anyone please let me know how to resolve
> this.
>
> Thanks,
> vedha
>
>
>
>
> --
> Vedha Vijayan
> Senior Software Engineer
> Comergent Technologies Inc.
> Ph:  650 232 5833
> Fax: 650 232 6010
> Email: vvijayan@comergent.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
www.ruchith.org
www.wso2.org

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org