java - WebServiceContext is null in Apache cxf Web services -
i'm trying set context of cxf apache web service using @resource annotation. context comes null. please overcome problem. below webservice i'm trying access messagecontext.
@webservice(servicename = "requestmanagerservice", targetnamespace = irmnamespaces.wsdl+irmversions.wsdl_version) @addressing(enabled=true, required=true) public class requestmanager implements irequestmanager{ @resource webservicecontext context; @webmethod(action = irmnamespaces.wsdl+irmversions.wsdl_version+"/requestmanagerservice/subscriberstatechangerequest", operationname = "subscriberstatechange") @oneway public void subscriberstatechangerequest( @webparam(partname = "subscriberstatechangerequest", name = "subscriberstatechangerequest", targetnamespace = irmnamespaces.service+irmversions.wsdl_version) subscriberstatechangerequesttype subscriberstatechangerequest) { messagecontext ctx = context.getmessagecontext();
below configuration part regarding above web service.
<bean id="rmservice" class="com.morpho.rm.core.base.process.service.requestmanager"> </bean> <jaxws:endpoint id="requestmangerintf" implementor="#rmservice" address="/requestmanager"> <jaxws:binding><soap:soapbinding version="1.2" mtomenabled="false"/></jaxws:binding> <jaxws:features> <wsa:addressing xmlns:wsa="http://cxf.apache.org/ws/addressing" /> </jaxws:features> <jaxws:properties> <entry key="schema-validation-enabled" value="true" /> </jaxws:properties> </jaxws:endpoint>
please if knows this.
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); }
Comments
Post a Comment