Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Soap Apache CXF不同类加载器问题_Soap_Cxf_Classloader - Fatal编程技术网

Soap Apache CXF不同类加载器问题

Soap Apache CXF不同类加载器问题,soap,cxf,classloader,Soap,Cxf,Classloader,我正在构建一个SOAP Web服务。 在这个SOAP Web服务中,我想将XML请求保存到一个文件中 要做到这一点,我知道我可以简单地使用一个链处理程序,但是,我需要其他信息,这些信息不是在请求本身中传输的,而是在Web服务中计算的,这就是为什么我觉得应该在Web服务中检索MessageContext 希望我可以使用@Resource获取WebServiceContext并检索消息上下文。但是,我似乎无法将MessageContext强制转换为我想要的类。以下是我的端点的代码: import o

我正在构建一个SOAP Web服务。 在这个SOAP Web服务中,我想将XML请求保存到一个文件中

要做到这一点,我知道我可以简单地使用一个链处理程序,但是,我需要其他信息,这些信息不是在请求本身中传输的,而是在Web服务中计算的,这就是为什么我觉得应该在Web服务中检索MessageContext

希望我可以使用@Resource获取WebServiceContext并检索消息上下文。但是,我似乎无法将MessageContext强制转换为我想要的类。以下是我的端点的代码:

import org.apache.cxf.jaxws.context.WrappedMessageContext;
[...]
public MyClass [...] {
[...]
    @Resource
    WebServiceContext wsContext;

    public WSResponse lister(SecurityInfo security, MessageId messageID, RequestBody body) { 
        if(wsContext.getMessageContext() instanceof WrappedMessageContext) { 
            //The code never goes in this
        }
        //However this : 
        wsContext.getMessageContext().getClass().toString(); //equals this : "org.apache.cxf.jaxws.context.WrappedMessageContext"
        //And this is where the problem is
        wsContext.getMessageContext().getClass().getClassLoader().toString(); // is : ModuleClassLoader for Module "org.apache.cxf.impl:main" [...]
        this.getClass().getClassLoader().toString(); // is : ModuleClassLoader for Module "deployment.my_ws_module.war:main" [...]
}
5天前我甚至还不知道CXF,昨天我发现了类加载器,但我想我有点理解为什么会发生这种情况,然而,当涉及到解决它时,我很不明白

值得注意的是:
该项目使用Maven、Spring、CXF和Java 1.8

基本上,您希望xml作为服务中的字符串,对吗?是的,就是这样。我知道如何从“SoapMessage”对象中读取它,我可以从WrappedMessageContext中提取,但是我不能将wsContext转换为WrappedMessageContext,因为它的类是由另一个类加载器加载的。