[英]WebServiceContext is null in Apache cxf Web services
我试图通过使用@Resource批注设置CXF Apache Web服务的上下文。 但是上下文始终为空。 请帮助克服这个问题。 以下是我正在尝试访问messageContext的Web服务。
@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();
以下是关于以上Web服务的配置部分。
<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>
如果有人对此有所了解,请提供帮助。
您必须在WS实现中使用Setter方法。
如果要在消息上下文中设置参数,则必须设置参数的范围应用程序。
在WS实现中,默认作用域是“处理程序”不可见
肥皂处理程序
public boolean handleMessage(SOAPMessageContext smc) {
smc.put("ID_MESSAGGIO",message.getId());
smc.setScope("ID_MESSAGGIO", MessageContext.Scope.APPLICATION);
}
WS实施
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);
}
无需使用带注释的WebServiceContext,而仅在需要时创建新实例。
WebServiceContext wsctx = new WebServiceContextImpl()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.