java - JaxWS RI /JaxB - Shared Object between Handler and WebMethod -


does exist way share object between handler , webmethod?

the reason why i'm asking want log raw request database, process request on storedprocedure (by id key) , log on same record raw response.

to want share id key between handler , webmethod , demand log of request , response raw handler.

tnx.

update

you must use setter method on ws implementation.

if want set parameter in message context must set scope application parameter.

the default scope handler not visible in ws implementation

soaphandler

 public boolean handlemessage(soapmessagecontext smc) {   smc.put("id_messaggio",message.getid());  smc.setscope("id_messaggio", messagecontext.scope.application);  } 

ws implementation

   webservicecontext context;      @resource     public void setcontext(webservicecontext context) {         this.context = context;     }        @override     public createandstartrequestbyvalueresponse   createandstartrequestbyvalue(createandstartrequestbyvaluerequest parameters) throws createandstartrequestbyvalueexception {          messagecontext messagecontext = context.getmessagecontext();          long thevalue = (long) messagecontext.get("id_messaggio");         return controller.startcreateandstartrequestbyvalue(parameters);     } 

tnx @ all.

jax-ws provides messagecontext purpose.

in handler:

 @override public boolean handlemessage(soapmessagecontext context) {   //this property checks whether handler being invoked service response   boolean request= ((boolean) context.get(soapmessagecontext.message_inbound_property)).booleanvalue();     if (request) { //check make sure handler operating on inbound message    context.setproperty("propertyname","propertyvalue");      }   return true; } 

in service implementation:

 @resource  webservicecontext wsctxt;   @webmethod  public yourserviceresponse operation(yourservicerequest req){       messagecontext msgctxt = wsctxt.getmessagecontext();      string thevalue = msgctxt.getproperty("propertyname").tostring(); //obligatory null check   } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -