1

静的な CXF 2.5.4 クライアントを動的に生成されるクライアントに変換しようとしています。次のコードを使用しました。

        JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        logger.info("Dynamically loading wsdl from " + theWsdlLocation);
        dynClient = dcf.createClient(theWsdlLocation, bindingFileList);
        if (dynClient == null) {
            logger.severe("dynClient creation not successful");
        } else {
            logger.info("Successful creation of service client from wsdl at " + theWsdlLocation);
        }
        ......
        http = (HTTPConduit) dynClient.getConduit();
        HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
        ClassLoader clAfterClientPolicy = httpClientPolicy.getClass().getClassLoader();
        httpClientPolicy.setConnectionTimeout(36000);
        httpClientPolicy.setAllowChunking(false);
        http.setClient(httpClientPolicy);
        .......
        ClassLoader threadCL = Thread.currentThread().getContextClassLoader();
        Object asrReq = threadCL.loadClass("com.microsoft.schemas.dynamics._2008._01.services.AddressServiceReadRequest").newInstance();
        .......
        Object [] asrRespObjs = dynClient.invoke("read", asrReq);

クライアントが dynClient.invoke メソッドを起動すると、次の例外がスローされます。

    org.apache.cxf.interceptor.Fault: Marshalling Error: com.microsoft.schemas.dynamics._2008._01.services.AddressServiceReadRequest is not known to this context
at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:261)
at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)

JAXB が asrReq オブジェクトをマーシャリングできない理由を誰か説明できますか?

4

1 に答える 1

1

次のようにクラスをロードする前に、コンテキストクラスローダーをリセットしてみてください。

Thread.currentThread().setContextClassloader(threadCL); 

説明されているように: ここ

于 2012-12-23T14:02:20.257 に答える