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 Dorner Thomas <th...@edmb.debis.com> on 2004/06/15 11:36:36 UTC

AW: How to get the SOAP Envelope from msg Context without invocat ion

Hi,
 
I am working on WS-security Handlers to sign and encrypt my SOAP.
I am interessted, if someone of you use the XML-Security API from Apache
instead of
the TSIK from Verisign?
 
If someone have me some Code-Snippet for the encrypt and decrypt Method, it
would be welcome :)
 
Thanks Tomi

-----Ursprüngliche Nachricht-----
Von: GANDHIRAJAN, AYYAPPAN [mailto:ayyappan.gandhirajan@hp.com]
Gesendet: Dienstag, 15. Juni 2004 11:29
An: axis-user@ws.apache.org
Betreff: RE: How to get the SOAP Envelope from msg Context without
invocation


Hi jose,
 
I dont know if it is helpful to you.
 
I adapted a different approach in this case. I created soap envelope first,
signed it and used call.invoke(envelope) api. This worked for me. if you are
interested, I can give the code snippet for you.


Thanks & regards, 
Ayyappan Gandhirajan 
----------------------------------------------------------------- 
Hewlett-Packard Global Delivery India Center 
Office: (+91) 80.2205.1472 
Mobile: (+91) 94483.14969       
Mail: ayyappan.gandhirajan@hp.com 
----------------------------------------------------------------- 

-----Original Message-----
From: Dhanush Gopinath [mailto:dhanush@mahindrabt.com]
Sent: Monday, June 07, 2004 10:07 AM
To: axis-user@ws.apache.org
Subject: Re: How to get the SOAP Envelope from msg Context without
invocation


Jose,
 
Handlers are called while request and response flows. It is an automatic
process... 
I dont know much more than this as I am also in the learning phase :) Hope
some one can help 
 
Dhanush

----- Original Message ----- 
From: Jose M. Selman <ma...@bee.cl>  
To: axis-user@ws.apache.org <ma...@ws.apache.org>  
Sent: Friday, June 04, 2004 7:47 PM
Subject: Re: How to get the SOAP Envelope from msg Context without
invocation

Is it possible to programatically set client-side handlers? That way my
problem would be solved. 
 
Cheers,
 
Jose M. Selman
 
 

----- Original Message ----- 
From: Dhanush Gopinath <ma...@mahindrabt.com>  
To: axis-user@ws.apache.org <ma...@ws.apache.org>  
Sent: Thursday, June 03, 2004 11:50 PM
Subject: Re: How to get the SOAP Envelope from msg Context without
invocation


Jose,
 
You wont be able to get a SOAPEnvelope at the client end after the call or
before the call .. because before the call there is no SOAPMessage and after
the Call the response is over. 
 
and Call.getMessgaeContext() will return a null value. So you cant access
that Message Context.
 
How ever you can do one thing. 
 
You can implement a Handler which will be invoked only in the requestFlow
and can then manipulate the SOAPMessage and the Handler end. 
 
To do that you must add a handler in the deploy.wsdd file and write a
Handler class which extends the BasicHandler class of Axis APIs. 
 
 <handler name="AttachmentHandler"
type="java:com.bt.oexgateway.webservices.AttachmentHandler"/>
 
  <service name="TestOAGXMLService" provider="java:RPC" style="rpc"
use="encoded">
    <requestFlow>
   <handler type="AttachmentHandler"/>
     </requestFlow>
    <responseFlow>
   <handler type="AttachmentHandler"/>
     </responseFlow>
....
</service>
 
The handler class will be something like this 
 
import org.apache.axis.handlers.BasicHandler;

public class AttachmentHandler extends BasicHandler
{
 public void invoke(MessageContext msgContext) throws AxisFault 
 {
  System.out.println("Hi Hi Handler Invoked !! ");
  
  //  Gets the Request SOAP Message  
   Message reqMsg = msgContext.getRequestMessage();
  //  Gets the response SOAP Message     
   Message respMsg = msgContext.getResponseMessage();
   
...
....
}
}
 
During the call from the client the method invoke() of the declared handler
is called . It depends on the declaration in the WSDD file . If  you need it
in both requestFlow and responseFlow then give as above wsdd. if you need
only in request then only <requestFlow> is needed.. Depends upon you and ur
application.
 
People, Hope I am right here.
Hope this helps you
 
Cheers 
Dhanush
 

----- Original Message ----- 
From: Jose M.  <ma...@bee.cl> Selman 
To: axis-user@ws.apache.org <ma...@ws.apache.org>  
Sent: Friday, June 04, 2004 8:00 AM
Subject: How to get the SOAP Envelope from msg Context without invocation


Hi:
    I'm writing an Axis Client that needs to send RPC style signed requests
according to XML-DSIG. My problem is that in order to sign the SOAP Envelope
I need to first have it! :-) I have looked everywhere but I haven't found
where to do this.

I'm doing

Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endPoint) );
call.setOperationName( new QName(endPoint, operationName) );
call.addParameter( "String", XMLType.XSD_STRING, ParameterMode.IN );
call.setReturnType( XMLType.XSD_STRING );
String resu = (String) call.invoke(new Object[] { "Some String Input" });

After this last statement I can get the SOAP Message from the message
context doing:

mc = call.getMessageContext();
env = request.getSOAPEnvelope();

But the service was already invoked!!!Is there any way of setting the
parameters used for a call without actually invoking the service?

Cheers,

Jose M Selman



*********************************************************

Disclaimer:        







This message (including any attachments) contains



confidential information intended for a specific



individual and purpose, and is protected by law.



If you are not the intended recipient, you should



delete this message and are hereby notified that



any disclosure, copying, or distribution of this

message, or the taking of any action based on it,



is strictly prohibited.



*********************************************************

Visit us at http://www.mahindrabt.com






*********************************************************

Disclaimer:         





This message (including any attachments) contains



confidential information intended for a specific



individual and purpose, and is protected by law.



If you are not the intended recipient, you should



delete this message and are hereby notified that



any disclosure, copying, or distribution of this

message, or the taking of any action based on it,



is strictly prohibited.



*********************************************************

Visit us at http://www.mahindrabt.com






Re: AW: How to get the SOAP Envelope from msg Context without invocat ion

Posted by Davanum Srinivas <da...@gmail.com>.
See http://ws.apache.org/ws-fx/wss4j/

-- dims

----- Original Message -----
From: Dorner Thomas <th...@edmb.debis.com>
Date: Tue, 15 Jun 2004 11:36:36 +0200
Subject: AW: How to get the SOAP Envelope from msg Context without invocat
	ion
To: "axis-user@ws.apache.org" <ax...@ws.apache.org>











Hi,

 

I am 
working on WS-security Handlers to sign and encrypt my SOAP.

I am 
interessted, if someone of you use the XML-Security API from Apache instead 
of

the 
TSIK from Verisign?

 

If 
someone have me some Code-Snippet for the encrypt and decrypt Method, it would 
be welcome :)

 

Thanks 
Tomi


  -----Ursprüngliche Nachricht-----
Von: GANDHIRAJAN, AYYAPPAN 
  [mailto:ayyappan.gandhirajan@hp.com]
Gesendet: Dienstag, 15. Juni 
  2004 11:29
An: axis-user@ws.apache.org
Betreff: RE: How to 
  get the SOAP Envelope from msg Context without invocation


  
Hi 
  jose,
  
 
  
I 
  dont know if it is helpful to you.
  
 
  
I 
  adapted a different approach in this case. I created soap envelope first, 
  signed it and used call.invoke(envelope) api. This worked for me. if you are 
  interested, I can give the code snippet for you.

  

Thanks & regards, 
Ayyappan Gandhirajan 
----------------------------------------------------------------- 
  
Hewlett-Packard Global Delivery India 
  Center 
Office: (+91) 80.2205.1472 
  
Mobile: (+91) 
  94483.14969       
Mail: ayyappan.gandhirajan@hp.com 
----------------------------------------------------------------- 
  
  

    -----Original Message-----
From: Dhanush Gopinath 
    [mailto:dhanush@mahindrabt.com]
Sent: Monday, June 07, 2004 10:07 
    AM
To: axis-user@ws.apache.org
Subject: Re: How to get 
    the SOAP Envelope from msg Context without invocation


    
Jose,
    
 
    
Handlers are called while request and response 
    flows. It is an automatic process... 
    
I dont know much more than this as I am also in the 
    learning phase :) Hope some one can help 
    
 
    
Dhanush
    

      ----- Original Message ----- 
      
From: 
      Jose M. Selman 
      
      
To: axis-user@ws.apache.org 
      
Sent: Friday, June 04, 2004 7:47 
      PM
      
Subject: Re: How to get the SOAP 
      Envelope from msg Context without invocation
      


      Is it possible to 
      programatically set client-side handlers? That way my problem would be 
      solved. 
      
 
      
Cheers,
      
 
      
Jose M. Selman
      
 
      
 
      

        ----- Original Message ----- 
        
From: 
        Dhanush Gopinath 
        
To: axis-user@ws.apache.org 
        
Sent: Thursday, June 03, 2004 11:50 
        PM
        
Subject: Re: How to get the SOAP 
        Envelope from msg Context without invocation
        


        
Jose,
        
 
        
You wont be able to get a SOAPEnvelope at the 
        client end after the call or before the call .. because before the call 
        there is no SOAPMessage and after the Call the response is over. 
        
        
 
        
and Call.getMessgaeContext() will return a null 
        value. So you cant access that Message Context.
        
 
        
How ever you can do one thing. 
        
 
        
You can implement a Handler which will be 
        invoked only in the requestFlow and can then manipulate the SOAPMessage 
        and the Handler end. 
        
 
        
To do that you must add a handler in the 
        deploy.wsdd file and write a Handler class which extends the 
        BasicHandler class of Axis APIs. 
        
 
        
 <handler name="AttachmentHandler" 
        type="java:com.bt.oexgateway.webservices.AttachmentHandler"/>
 
  
        <service name="TestOAGXMLService" provider="java:RPC" style="rpc" 
        use="encoded">
    
        <requestFlow>
   <handler 
        type="AttachmentHandler"/>
     
        </requestFlow>
    
        <responseFlow>
   <handler 
        type="AttachmentHandler"/>
     
        </responseFlow>
....
        
</service>
        
 
        
The handler class will be something like this 
        
        
 
        
import 
        org.apache.axis.handlers.BasicHandler;

        
public class AttachmentHandler extends 
        BasicHandler
{
        
 public void invoke(MessageContext 
        msgContext) throws AxisFault 
        
 {
  System.out.println("Hi Hi Handler Invoked !! 
        ");
  
  //  Gets the Request SOAP 
        Message  
   Message reqMsg = 
        msgContext.getRequestMessage();
  //  Gets the 
        response SOAP Message 
            
   Message respMsg = 
        msgContext.getResponseMessage();
   
        
...
        
....
        
}
        
}
        
 
        
During the call from the client the method 
        invoke() of the declared handler is called . It depends on the 
        declaration in the WSDD file . If  you need it in both requestFlow 
        and responseFlow then give as above wsdd. if you need only in request 
        then only <requestFlow> is needed.. Depends upon you and ur 
        application.
        
 
        
People, Hope I am right here.
        
Hope this helps you
        
 
        
Cheers 
        
Dhanush
        
 
        

          ----- Original Message ----- 
          
From: 
          Jose M. 
          Selman 
          
To: axis-user@ws.apache.org 
          
          
Sent: Friday, June 04, 2004 8:00 
          AM
          
Subject: How to get the SOAP 
          Envelope from msg Context without invocation
          

Hi:
    
          I'm writing an Axis Client that needs to send RPC style signed 
          requests
according to XML-DSIG. My problem is that in order to sign 
          the SOAP Envelope
I need to first have it! :-) I have looked 
          everywhere but I haven't found
where to do this.

I'm 
          doing

Service service = new Service();
Call call = (Call) 
          service.createCall();
call.setTargetEndpointAddress( new 
          java.net.URL(endPoint) );
call.setOperationName( new 
          QName(endPoint, operationName) );
call.addParameter( "String", 
          XMLType.XSD_STRING, ParameterMode.IN );
call.setReturnType( 
          XMLType.XSD_STRING );
String resu = (String) call.invoke(new 
          Object[] { "Some String Input" });

After this last statement I 
          can get the SOAP Message from the message
context doing:

mc 
          = call.getMessageContext();
env = 
          request.getSOAPEnvelope();

But the service was already 
          invoked!!!Is there any way of setting the
parameters used for a 
          call without actually invoking the service?

Cheers,

Jose 
          M Selman

        

          
          

            *********************************************************
Disclaimer:        



This message (including any attachments) contains

confidential information intended for a specific

individual and purpose, and is protected by law.

If you are not the intended recipient, you should

delete this message and are hereby notified that

any disclosure, copying, or distribution of this
message, or the taking of any action based on it,

is strictly prohibited.

*********************************************************
Visit us at http://www.mahindrabt.com


    

      
      

        *********************************************************
Disclaimer:         


This message (including any attachments) contains

confidential information intended for a specific

individual and purpose, and is protected by law.

If you are not the intended recipient, you should

delete this message and are hereby notified that

any disclosure, copying, or distribution of this
message, or the taking of any action based on it,

is strictly prohibited.

*********************************************************
Visit us at http://www.mahindrabt.com





-- 
Davanum Srinivas - http://webservices.apache.org/~dims/