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 Sanjay Vivek <Sa...@newcastle.ac.uk> on 2008/03/03 17:35:32 UTC
Error when obtaining UsernameToken information from a different class.
Hi all,
I've a policy based service that returns the UsernameToken information
of the authenticated user. However, I wish to obtain the UsenameToken
information from a separate class as shown below:
public class PolicyEchoService {
public String echo() {
AuthUser authuser = new AuthUser();
String user = authuser.getAuth();
return("The authenticated user was" + user);
}
}//end of PolicyEchoService
Where AuthUser.java:
public class AuthUser {
public String getAuth() {
//user variable
String user=null;
MessageContext msgCtx =
MessageContext.getCurrentMessageContext();
Vector results = null;
if ((results = (Vector) msgCtx
.getProperty(WSHandlerConstants.RECV_RESULTS)) == null)
{
System.out.println("No security results!!");
throw new RuntimeException("No security results!!");
} else {
System.out.println("Number of results: " + results.size());
for (int i = 0; i < results.size(); i++) {
WSHandlerResult rResult = (WSHandlerResult)
results.get(i);
Vector wsSecEngineResults = rResult.getResults();
for (int j = 0; j < wsSecEngineResults.size(); j++) {
WSSecurityEngineResult wser =
(WSSecurityEngineResult) wsSecEngineResults.get(j);
if (wser.getAction() == WSConstants.UT
&& wser.getPrincipal() != null) {
//Extract the principal
WSUsernameTokenPrincipal principal =
(WSUsernameTokenPrincipal)wser.getPrincipal();
//Get user/pass
user = principal.getName();
}
}
}
return user;
}
}
}// end of AuthUser
So basically my PolicyEchoService.aar is:
+META-INF
-services.xml
+policy
- PolicyEchoService.class
- AuthUser.class
- PWHandler.class
However, when I try to call the service with my client, I get the
exceptions shown below. What am I doing wrong? Can I invoke Rampart
methods from a different class or is this not allowed? Any pointers will
be very helpful. Cheers.
Exception in thread "main" org.apache.axis2.AxisFault: Message Receiver
not found for AxisOperation: echo
at
org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java
:486)
at
org.apache.axis2.description.OutInAxisOperationClient.handleResponse(Out
InAxisOperation.java:343)
at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOper
ation.java:389)
at
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInA
xisOperation.java:211)
at
org.apache.axis2.client.OperationClient.execute(OperationClient.java:163
)
at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528
)
at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508
)
at
org.apache.rampart.altpolicy.CommandLineClient.main(CommandLineClient.ja
va:66)
Regards
--------------
Sanjay Vivek
Web Analyst
Middleware Team
ISS
University of Newcastle Upon Tyne
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Error when obtaining UsernameToken information from a different class.
Posted by Ruchith Fernando <ru...@gmail.com>.
HI Sanjay,
Your services.xml looks fine ... but the only situation that Axis2 can
throw this error is when the services.xml does not specify the
messageReceiver. Please check the services.xml file in your deployed
service archive.
Thanks,
Ruchith
On Tue, Mar 4, 2008 at 2:31 PM, Sanjay Vivek
<Sa...@newcastle.ac.uk> wrote:
> Hi Nandana,
>
> I've attached the services.xml with this email. Thanks again for your
> help. Cheers.
>
> Regards
> Sanjay
>
>
>
> >-----Original Message-----
> >From: Nandana Mihindukulasooriya [mailto:nandana.cse@gmail.com]
> >Sent: 04 March 2008 08:11
> >To: axis-user@ws.apache.org
> >Subject: Re: Error when obtaining UsernameToken information
> >from a different class.
> >
> >Hi Sanjay,
> > Can you please post the services.xml you used ? Error
> >message says "Message Receiver not found for AxisOperation:
> >echo". It is thrown by the AxisEngine when the message
> >receiver is null.
> >
> >thanks,
> >/nandana
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
--
http://blog.ruchith.org
http://wso2.org
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
RE: Error when obtaining UsernameToken information from a different class.
Posted by Sanjay Vivek <Sa...@newcastle.ac.uk>.
Hi Nandana,
I've attached the services.xml with this email. Thanks again for your
help. Cheers.
Regards
Sanjay
>-----Original Message-----
>From: Nandana Mihindukulasooriya [mailto:nandana.cse@gmail.com]
>Sent: 04 March 2008 08:11
>To: axis-user@ws.apache.org
>Subject: Re: Error when obtaining UsernameToken information
>from a different class.
>
>Hi Sanjay,
> Can you please post the services.xml you used ? Error
>message says "Message Receiver not found for AxisOperation:
>echo". It is thrown by the AxisEngine when the message
>receiver is null.
>
>thanks,
>/nandana
>
Re: Error when obtaining UsernameToken information from a different class.
Posted by Nandana Mihindukulasooriya <na...@gmail.com>.
Hi Sanjay,
Can you please post the services.xml you used ? Error message
says "Message Receiver not found for AxisOperation: echo". It is
thrown by the AxisEngine when the message receiver is null.
thanks,
/nandana
On Mon, Mar 3, 2008 at 10:05 PM, Sanjay Vivek
<Sa...@newcastle.ac.uk> wrote:
> Hi all,
>
> I've a policy based service that returns the UsernameToken information
> of the authenticated user. However, I wish to obtain the UsenameToken
> information from a separate class as shown below:
>
> public class PolicyEchoService {
>
> public String echo() {
>
> AuthUser authuser = new AuthUser();
> String user = authuser.getAuth();
>
> return("The authenticated user was" + user);
>
> }
> }//end of PolicyEchoService
>
>
> Where AuthUser.java:
>
>
> public class AuthUser {
>
> public String getAuth() {
>
> //user variable
> String user=null;
>
>
> MessageContext msgCtx =
> MessageContext.getCurrentMessageContext();
> Vector results = null;
> if ((results = (Vector) msgCtx
> .getProperty(WSHandlerConstants.RECV_RESULTS)) == null)
> {
> System.out.println("No security results!!");
> throw new RuntimeException("No security results!!");
> } else {
> System.out.println("Number of results: " + results.size());
> for (int i = 0; i < results.size(); i++) {
> WSHandlerResult rResult = (WSHandlerResult)
> results.get(i);
> Vector wsSecEngineResults = rResult.getResults();
>
> for (int j = 0; j < wsSecEngineResults.size(); j++) {
> WSSecurityEngineResult wser =
> (WSSecurityEngineResult) wsSecEngineResults.get(j);
> if (wser.getAction() == WSConstants.UT
> && wser.getPrincipal() != null) {
>
> //Extract the principal
> WSUsernameTokenPrincipal principal =
> (WSUsernameTokenPrincipal)wser.getPrincipal();
>
> //Get user/pass
> user = principal.getName();
>
> }
> }
> }
>
> return user;
> }
>
> }
>
> }// end of AuthUser
>
>
> So basically my PolicyEchoService.aar is:
>
> +META-INF
> -services.xml
>
> +policy
> - PolicyEchoService.class
> - AuthUser.class
> - PWHandler.class
>
>
> However, when I try to call the service with my client, I get the
> exceptions shown below. What am I doing wrong? Can I invoke Rampart
> methods from a different class or is this not allowed? Any pointers will
> be very helpful. Cheers.
>
>
>
> Exception in thread "main" org.apache.axis2.AxisFault: Message Receiver
> not found for AxisOperation: echo
> at
> org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java
> :486)
> at
> org.apache.axis2.description.OutInAxisOperationClient.handleResponse(Out
> InAxisOperation.java:343)
> at
> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOper
> ation.java:389)
> at
> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInA
> xisOperation.java:211)
> at
> org.apache.axis2.client.OperationClient.execute(OperationClient.java:163
> )
> at
> org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528
> )
> at
> org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508
> )
> at
> org.apache.rampart.altpolicy.CommandLineClient.main(CommandLineClient.ja
> va:66)
>
>
> Regards
> --------------
> Sanjay Vivek
> Web Analyst
> Middleware Team
> ISS
> University of Newcastle Upon Tyne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
http://nandana83.blogspot.com/
http://nandanasm.wordpress.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org