gpt4 book ai didi

java - WebServiceContext 在 Apache cxf Web 服务中为空

转载 作者:行者123 更新时间:2023-11-29 09:32:17 25 4
gpt4 key购买 nike

我正在尝试使用 @Resource 注释设置 CXF Apache Web 服务的上下文。但是上下文总是空的。请帮助克服这个问题。下面是我正在尝试访问 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();

下面是关于上述网络服务的配置部分。

<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);
}

关于java - WebServiceContext 在 Apache cxf Web 服务中为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24421036/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com