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 蘇 軼(CEC) <s_...@cec-ltd.co.jp> on 2006/05/23 10:44:50 UTC

[Axis2]How to process SOAP header in service class? or handler class?

hi, all:

I want to get the value of SOAP header in handler class
(maybe service class?), how can I do that?

Any help or web resources are great appreciated !
Thanks again.

- sukie

Re: [Axis2]How to process SOAP header in service class? or handler class?

Posted by 蘇 軼(CEC) <s_...@cec-ltd.co.jp>.
hi Deepal,

Thank you very much for your help !

Regards,
- sukie

----- Original Message ----- 
From: "Deepal Jayasinghe" <de...@opensource.lk>
To: <ax...@ws.apache.org>
Sent: Thursday, June 22, 2006 2:01 AM
Subject: Re: [Axis2]How to process SOAP header in service class? or handler
class?


> hi Sukie;
> Sorry for late reply;
> >From the operationContext you can get the corresponding AxisOperation
> and name of the axis operation will be the method name that the client
> is trying to invoke.
>
> 蘇 軼(CEC) wrote:
>
> >hi deepal,
> >
> >Thank you very much for your help and sorry for late reply.
> >
> >I have understood the usage of the setOperationContext() method,
> >but  I means how to know which method (echo() or add()) the client
> >is invoking in setOperationContext() method? For example, process
> >the WSSE header when client invokes add() method but do nothing
> >when client invokes echo() method?
> >
> >In fact, could I program like below?
> >
> >public void setOperationContext (OperationConetxt opctx) {
> >    if (XxxClass.getCurrentInvokedMethodName().equals("add")) {
> >        // process WSSE header
> >    } else {
> >        // do nothing
> >    }
> >}
> >
> >Thanks again !
> >
> >- sukie
> >
> >
> >
> >
> >>>2. The setOperationContext(...) method is ONE method,
> >>>   what could I do when I want to deal headers in different
> >>>   way because client calls different method?
> >>>
> >>>
> >>>
> >>>
> >>I think you are missing smt , say your service impl class is as follows
> >>
> >>class MyService {
> >>public void setOperationContext (OperationConetxt opctx) {
> >>}
> >>
> >>public String echo(String val){
> >>return val;
> >>}
> >>
> >>public int add(int a , int b){
> >>return a + b;
> >>}
> >>}
> >>
> >>So client can call either add or echo but not the setOperationContex ,
> >>coz that method is not visible to him. If he call either add or echo
> >>setOperationConetxt method will be called. When there is a req for ur
> >>service and if the service has setOperationConetxt method then first it
> >>will called setOperationContext and then it will called the actual java
> >>method client want to invoke.
> >>
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> >For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
> >
> >
> >
>
> -- 
> Thanks,
> Deepal
> ................................................................
> ~Future is Open~
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>


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


Re: [Axis2]How to process SOAP header in service class? or handler class?

Posted by Deepal Jayasinghe <de...@opensource.lk>.
hi Sukie;
Sorry for late reply;
>>From the operationContext you can get the corresponding AxisOperation
and name of the axis operation will be the method name that the client
is trying to invoke.

蘇 軼(CEC) wrote:

>hi deepal,
>
>Thank you very much for your help and sorry for late reply.
>
>I have understood the usage of the setOperationContext() method,
>but  I means how to know which method (echo() or add()) the client
>is invoking in setOperationContext() method? For example, process 
>the WSSE header when client invokes add() method but do nothing 
>when client invokes echo() method?
>
>In fact, could I program like below?
>
>public void setOperationContext (OperationConetxt opctx) {
>    if (XxxClass.getCurrentInvokedMethodName().equals("add")) {
>        // process WSSE header
>    } else {
>        // do nothing
>    }
>}
>
>Thanks again !
>
>- sukie
>
>
>  
>
>>>2. The setOperationContext(...) method is ONE method,
>>>   what could I do when I want to deal headers in different
>>>   way because client calls different method?
>>> 
>>>
>>>      
>>>
>>I think you are missing smt , say your service impl class is as follows
>>
>>class MyService {
>>public void setOperationContext (OperationConetxt opctx) {
>>}
>>
>>public String echo(String val){
>>return val;
>>}
>>
>>public int add(int a , int b){
>>return a + b;
>>}
>>}
>>
>>So client can call either add or echo but not the setOperationContex ,
>>coz that method is not visible to him. If he call either add or echo
>>setOperationConetxt method will be called. When there is a req for ur
>>service and if the service has setOperationConetxt method then first it
>>will called setOperationContext and then it will called the actual java
>>method client want to invoke.
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>
>  
>

-- 
Thanks,
Deepal
................................................................
~Future is Open~ 




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


Re: [Axis2]How to process SOAP header in service class? or handler class?

Posted by 蘇 軼(CEC) <s_...@cec-ltd.co.jp>.
hi deepal,

Thank you very much for your help and sorry for late reply.

I have understood the usage of the setOperationContext() method,
but  I means how to know which method (echo() or add()) the client
is invoking in setOperationContext() method? For example, process 
the WSSE header when client invokes add() method but do nothing 
when client invokes echo() method?

In fact, could I program like below?

public void setOperationContext (OperationConetxt opctx) {
    if (XxxClass.getCurrentInvokedMethodName().equals("add")) {
        // process WSSE header
    } else {
        // do nothing
    }
}

Thanks again !

- sukie


> >2. The setOperationContext(...) method is ONE method,
> >    what could I do when I want to deal headers in different
> >    way because client calls different method?
> >  
> >
> I think you are missing smt , say your service impl class is as follows
> 
> class MyService {
> public void setOperationContext (OperationConetxt opctx) {
> }
> 
> public String echo(String val){
> return val;
> }
> 
> public int add(int a , int b){
> return a + b;
> }
> }
> 
> So client can call either add or echo but not the setOperationContex ,
> coz that method is not visible to him. If he call either add or echo
> setOperationConetxt method will be called. When there is a req for ur
> service and if the service has setOperationConetxt method then first it
> will called setOperationContext and then it will called the actual java
> method client want to invoke.


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


Re: [Axis2]How to process SOAP header in service class? or handler class?

Posted by Deepal Jayasinghe <de...@opensource.lk>.
Hi Sukie;
pls see my comment blow;

蘇 軼(CEC) wrote:

>hi Chinthaka,
>
>Thank you for your help !
>
>Please let me ask tow more question :
>
>1. If I don't use RawXMLINOutMessageReceiver, I can't
>    process headers in service method?
>  
>
If you use any of the default message receivers in Axis2 you can get
access to OperationContext , only requirement is to have
setOperationContext method in service impl class.

>2. The setOperationContext(...) method is ONE method,
>    what could I do when I want to deal headers in different
>    way because client calls different method?
>  
>
I think you are missing smt , say your service impl class is as follows

class MyService {
public void setOperationContext (OperationConetxt opctx) {
}

public String echo(String val){
return val;
}

public int add(int a , int b){
return a + b;
}
}

So client can call either add or echo but not the setOperationContex ,
coz that method is not visible to him. If he call either add or echo
setOperationConetxt method will be called. When there is a req for ur
service and if the service has setOperationConetxt method then first it
will called setOperationContext and then it will called the actual java
method client want to invoke.

>Thank you !
>
>- sukie
>
>
>----- Original Message ----- 
>From: "Eran Chinthaka" <ch...@opensource.lk>
>To: <ax...@ws.apache.org>
>Sent: Wednesday, May 24, 2006 6:35 PM
>Subject: Re: [Axis2]How to process SOAP header in service class? or handler
>class?
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>
>  
>

-- 
Thanks,
Deepal
................................................................
~Future is Open~ 



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


Re: [Axis2]How to process SOAP header in service class? or handler class?

Posted by 蘇 軼(CEC) <s_...@cec-ltd.co.jp>.
hi Chinthaka,

Thank you for your help !

Please let me ask tow more question :

1. If I don't use RawXMLINOutMessageReceiver, I can't
    process headers in service method?

2. The setOperationContext(...) method is ONE method,
    what could I do when I want to deal headers in different
    way because client calls different method?

Thank you !

- sukie


----- Original Message ----- 
From: "Eran Chinthaka" <ch...@opensource.lk>
To: <ax...@ws.apache.org>
Sent: Wednesday, May 24, 2006 6:35 PM
Subject: Re: [Axis2]How to process SOAP header in service class? or handler
class?



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


Re: [Axis2]How to process SOAP header in service class? or handler class?

Posted by Eran Chinthaka <ch...@opensource.lk>.
Put the following method in your service impl class.

public void setOperationContext(OperationContext opContext){
       MessageContext  inMsgCtxt =
opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
SOAPEnvelope envelope = inMsgCtxt.getEnvelope();

// do whatever you want with this envelope.

}

And use RawXMLINOutMessageReceiver. The above method in your service
impl class  will automatically be called by Axis2 thru IOC.


-- Chinthaka


蘇 軼(CEC) wrote:
> hi Eran,
> 
> Thanks for your help!
> 
> But In a service class, for example the sample MyService class,
> the parameter is an OMElement object(I think it is the body element
> of SOAP message, isn't it?),  how can I get the header?
> 
> I'm a newbie and THANKS again !
> 
> - sukie
> 
> ----- Original Message ----- 
> From: "Eran Chinthaka" <ch...@opensource.lk>
> To: <ax...@ws.apache.org>
> Sent: Tuesday, May 23, 2006 5:57 PM
> Subject: Re: [Axis2]How to process SOAP header in service class? or handler
> class?
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 


Re: [Axis2]How to process SOAP header in service class? or handler class?

Posted by 蘇 軼(CEC) <s_...@cec-ltd.co.jp>.
hi Eran,

Thanks for your help!

But In a service class, for example the sample MyService class,
the parameter is an OMElement object(I think it is the body element
of SOAP message, isn't it?),  how can I get the header?

I'm a newbie and THANKS again !

- sukie

----- Original Message ----- 
From: "Eran Chinthaka" <ch...@opensource.lk>
To: <ax...@ws.apache.org>
Sent: Tuesday, May 23, 2006 5:57 PM
Subject: Re: [Axis2]How to process SOAP header in service class? or handler
class?



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


Re: [Axis2]How to process SOAP header in service class? or handler class?

Posted by Eran Chinthaka <ch...@opensource.lk>.
What do u mean by value of a SOAP header ?

Anyway you can access the soap message, including soap headers, within a
handler by calling messageContext.getEnvelope().

-- Chinthaka


蘇 軼(CEC) wrote:
> hi, all:
>  
> I want to get the value of SOAP header in handler class
> (maybe service class?), how can I do that?
>  
> Any help or web resources are great appreciated !
> Thanks again.
>  
> - sukie