0

我正在尝试实现一个将显示 SSRS 报告的 Java Spring 应用程序。我一直在关注本教程:http: //blogs.msdn.com/b/christophputz/archive/2010/05/07/accessing-ms-reporting-services-with-java.aspx。但在某个时候,我遇到了一个问题。

我下载了最新版本的 Metro wsimport(wsimport 版本“2.2.8”)。

我使用以下命令生成 Web 服务:

wsimport -s -extension src http://devwin/reports/ReportExecution2005.asmx?wsdl
parsing WSDL...
[WARNING] SOAP port "ReportExecutionServiceSoap12": uses a non-standard SOAP 1.2 binding line 1885 of http://devwin/reports/ReportExecution2005.asmx?wsdl
Generating code...
Compiling code...

wsimport -s src -extension http://devwin/reports/ReportService2005.asmx?wsdl
parsing WSDL...
[WARNING] SOAP port "ReportingService2005Soap12": uses a non-standard SOAP 1.2 binding. line 5841 of http://devwin/reports/ReportService2005.asmx?wsdl
Generating code...
Compiling code...

我导入了生成的源代码(/src 只是因为主题中提到的错误)。

我使用了以下 Maven 依赖项

<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-rt</artifactId>
    <version>2.2.8</version>
</dependency>

这是我的班级调用报告:

import java.util.List;

import javax.xml.ws.BindingProvider;
import javax.xml.ws.Holder;

import com.iphos.rankingcheck.entity.Report;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ArrayOfParameterValue;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ArrayOfString;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ArrayOfWarning;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionHeader;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionInfo;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ParameterValue;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ReportExecutionService;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ReportExecutionServiceSoap;
import com.sun.xml.ws.developer.WSBindingProvider;

public class ReportServiceCaller {
    public static void callReportWS(Report report) {
        String reportPath = "/Path/Report";
        String format = "HTML4.0";
        String historyID = null;
        String devInfo = "<DeviceInfo><Toolbar>False</Toolbar><HTMLFragment>True</HTMLFragment></DeviceInfo>";
        String executionID = null;

        Holder<String> extension = null;
        Holder<String> mimeType = null;
        Holder<String> encoding = null;
        Holder<ArrayOfWarning> warnings = null;
        Holder<ArrayOfString> streamIDs = null;
        Holder<byte[]> result = new Holder<byte[]>();

        ReportExecutionService res = new ReportExecutionService();
        ReportExecutionServiceSoap ress = res.getReportExecutionServiceSoap();

        BindingProvider bp = (BindingProvider)ress;
        WSBindingProvider wsbp = (WSBindingProvider)ress;

        // Sessions erlauben
        bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);

        ExecutionInfo execInfo = new ExecutionInfo();

        // Parameterliste erzeugen
        ArrayOfParameterValue apv = new ArrayOfParameterValue();
        List<ParameterValue> apvList = apv.getParameterValue();     

        ParameterValue param0 = new ParameterValue();
        param0.setName("Project");
        param0.setValue(report.getProject().getProjectName());
        apvList.add(param0);

        // Report vorbereiten
        execInfo = ress.loadReport(reportPath, historyID);
        // ExecutionID für den nächsten Aufruf merken
        executionID = execInfo.getExecutionID();       
        bp.getRequestContext().put("sessionID", executionID);

        // ExecutionHeader Element erzeugen und es für den nächsten Aufruf
        // and den WSBindingProvider übergeben
        ExecutionHeader eh = new ExecutionHeader();
        eh.setExecutionID(executionID);
        wsbp.setOutboundHeaders(eh);

        // Parameter an den Report übergeben
        ress.setExecutionParameters(apv, "en-us");

        // Report anfordern
        ress.render(format, devInfo, result, extension, mimeType, encoding, warnings, streamIDs);
        // Ergebnis des Aufrufs ausgeben
        String resultString = new String(result.value);  
    }
}

当我尝试运行报告时,出现以下异常:

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(Ljava/lang/Object;Ljava/io/OutputStream;Ljavax/xml/namespace/NamespaceContext;)V
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:839)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause

java.lang.NoSuchMethodError: com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(Ljava/lang/Object;Ljava/io/OutputStream;Ljavax/xml/namespace/NamespaceContext;)V
    com.sun.xml.ws.db.glassfish.MarshallerBridge.marshal(MarshallerBridge.java:86)
    com.sun.xml.bind.api.Bridge.marshal(Bridge.java:105)
    com.sun.xml.ws.message.jaxb.JAXBHeader.writeTo(JAXBHeader.java:201)
    com.sun.xml.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:148)
    com.sun.xml.ws.api.message.MessageWrapper.writeTo(MessageWrapper.java:230)
    com.sun.xml.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:134)
    com.sun.xml.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:242)
    com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:223)
    com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:143)
    com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:110)
    com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
    com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
    com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
    com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
    com.sun.xml.ws.client.Stub.process(Stub.java:464)
    com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:174)
    com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
    com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:91)
    com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:154)
    com.sun.proxy.$Proxy93.setExecutionParameters(Unknown Source)
    com.iphos.rankingcheck.util.ReportServiceCaller.callReportWS(ReportServiceCaller.java:79)
    com.iphos.rankingcheck.controller.ReportController.display(ReportController.java:209)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:601)
    org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

我发现可能缺少该方法的实现,因此我尝试搜索依赖项来提供它。我找到了一些,但我只能用那个例外来摆脱那个例外:

<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.2.7</version>
</dependency>

当我添加它时,我得到了以下异常:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is javax.xml.ws.WebServiceException: com.sun.istack.XMLStreamException2: javax.xml.bind.JAXBException: class com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionHeader nor any of its super class is known to this context.
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:681)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause

javax.xml.ws.WebServiceException: com.sun.istack.XMLStreamException2: javax.xml.bind.JAXBException: class com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionHeader nor any of its super class is known to this context.
    com.sun.xml.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:137)
    com.sun.xml.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:242)
    com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:223)
    com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:143)
    com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:110)
    com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
    com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
    com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
    com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
    com.sun.xml.ws.client.Stub.process(Stub.java:464)
    com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:174)
    com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
    com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:91)
    com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:154)
    com.sun.proxy.$Proxy93.setExecutionParameters(Unknown Source)
    com.iphos.rankingcheck.util.ReportServiceCaller.callReportWS(ReportServiceCaller.java:79)
    com.iphos.rankingcheck.controller.ReportController.display(ReportController.java:209)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:601)
    org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause

com.sun.istack.XMLStreamException2: javax.xml.bind.JAXBException: class com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionHeader nor any of its super class is known to this context.
    com.sun.xml.ws.message.jaxb.JAXBHeader.writeTo(JAXBHeader.java:206)
    com.sun.xml.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:148)
    com.sun.xml.ws.api.message.MessageWrapper.writeTo(MessageWrapper.java:230)
    com.sun.xml.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:134)
    com.sun.xml.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:242)
    com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:223)
    com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:143)
    com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:110)
    com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
    com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
    com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
    com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
    com.sun.xml.ws.client.Stub.process(Stub.java:464)
    com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:174)
    com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
    com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:91)
    com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:154)
    com.sun.proxy.$Proxy93.setExecutionParameters(Unknown Source)
    com.iphos.rankingcheck.util.ReportServiceCaller.callReportWS(ReportServiceCaller.java:79)
    com.iphos.rankingcheck.controller.ReportController.display(ReportController.java:209)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:601)
    org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause

javax.xml.bind.JAXBException: class com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionHeader nor any of its super class is known to this context.
    com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:593)
    com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:482)
    com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
    com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:173)
    com.sun.xml.ws.db.glassfish.MarshallerBridge.marshal(MarshallerBridge.java:86)
    com.sun.xml.bind.api.Bridge.marshal(Bridge.java:145)
    com.sun.xml.ws.message.jaxb.JAXBHeader.writeTo(JAXBHeader.java:201)
    com.sun.xml.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:148)
    com.sun.xml.ws.api.message.MessageWrapper.writeTo(MessageWrapper.java:230)
    com.sun.xml.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:134)
    com.sun.xml.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:242)
    com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:223)
    com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:143)
    com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:110)
    com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
    com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
    com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
    com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
    com.sun.xml.ws.client.Stub.process(Stub.java:464)
    com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:174)
    com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
    com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:91)
    com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:154)
    com.sun.proxy.$Proxy93.setExecutionParameters(Unknown Source)
    com.iphos.rankingcheck.util.ReportServiceCaller.callReportWS(ReportServiceCaller.java:79)
    com.iphos.rankingcheck.controller.ReportController.display(ReportController.java:209)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:601)
    org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

我尝试添加其他依赖项,例如:webservices-rt、webservices-osgi 等,但我无法解决问题。

任何建议将不胜感激。

4

3 回答 3

0

这些错误消息似乎都不是来自 RS 端。如果您的目标只是在您的 Java 应用程序中显示报告,您是否考虑过通过 URL 访问来显示报告(在任何类型的应用程序中)?

如果您确实需要使用 Web 服务,我建议您在 RS 端启用详细日志记录和 HTTP 日志记录,以查看 RS 对请求的真正抱怨是什么。

于 2013-07-30T18:08:56.120 回答
0

这是使用轴的解决方案。

构建.gradle

dependencies {
    compile('commons-discovery:commons-discovery:0.5')
    compile('org.apache.axis:axis:1.4')
    compile('org.apache.axis:axis-jaxrpc:1.4')
    compile('org.apache.axis:axis-saaj:1.4')
    compile('axis:axis-wsdl4j:1.5.1')

    axisGenAntTask 'org.apache.axis:axis-ant:1.4',
        'org.apache.axis:axis:1.4',
        'org.apache.axis:axis-jaxrpc:1.4',
        'axis:axis-wsdl4j:1.5.1',
        'commons-codec:commons-codec:1.3',
        'commons-logging:commons-logging:1.1.1',
        'commons-discovery:commons-discovery:0.2'
}

task genWsdlClasses {
    doLast {
        def destDir = file("${buildDir}/generated/src/main/java")

        ant.taskdef(name: 'genClassesFromWSDL',
                    classname: 'org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask',
                    classpath: configurations.axisGenAntTask.asPath)

        destDir.mkdirs()

        ant.genClassesFromWSDL(url: "pathOrUrlToWsdl", output: destDir, username: "optionalUsername", password: "optionalPwd");
    }
}

sourceSets {
    generated {
        java.srcDirs "${buildDir}/generated/src/main/java"
    }

    main {
        compileClasspath += generated.output
        runtimeClasspath += generated.output
    }

    test {
        compileClasspath += generated.output
        runtimeClasspath += generated.output
    }
}

compileGeneratedJava {
    dependsOn(genWsdlClasses)
    classpath = configurations.compile
}

compileJava{
    dependsOn(compileGeneratedJava)
    source += sourceSets.generated.java
}

爪哇代码

public String getHtml(String reportPath, Map<String, String> reportParameters) {
        try {
            ReportExecutionService reportExecution = new ReportExecutionServiceLocator();
            ReportExecutionServiceSoapStub ress = (ReportExecutionServiceSoapStub) reportExecution.getReportExecutionServiceSoap();

            final ExecutionInfo info = ress.loadReport(reportPath, null);
            final String executionId = info.getExecutionID();

            SOAPHeaderElement sessionHeader = new SOAPHeaderElement(
                    "http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices",
                    "ExecutionHeader");
            SOAPElement addChildElement = sessionHeader.addChildElement("ExecutionID");
            addChildElement.addTextNode(executionId);
            ress.setHeader(sessionHeader);

            final ParameterValue[] parameters = new ParameterValue[reportParameters != null ? reportParameters.size() : 0];
            if (reportParameters != null && !reportParameters.isEmpty()) {
                int i = 0;
                for (final String name : reportParameters.keySet()) {
                    final String value = reportParameters.get(name);
                    ParameterValue parameterValue = new ParameterValue();
                    parameterValue.setName(name);
                    parameterValue.setValue(value);

                    parameters[i++] = parameterValue;
                }
            }
            ress.setExecutionParameters(parameters, "en-us");

            String format = "HTML4.0";
            String devInfo = "<DeviceInfo><Toolbar>False</Toolbar><HTMLFragment>True</HTMLFragment></DeviceInfo>";
            final ByteArrayHolder result = new ByteArrayHolder();
            final StringHolder extension = new StringHolder();
            final StringHolder mimeType = new StringHolder("text/html");
            final StringHolder encoding = new StringHolder(StandardCharsets.UTF_8.name());
            final ArrayOfWarningHolder warnings = new ArrayOfWarningHolder();
            final ArrayOfStringHolder streamIds = new ArrayOfStringHolder();

            ress.render(format, devInfo, result, extension, mimeType, encoding, warnings, streamIds);

            return new String(result.value);
        } catch (Exception e) {
            throw new RuntimeException("Report generation error", e);
        }
    }
于 2017-07-07T03:10:46.943 回答
-2

我通过使用与 Metro 不同的工具解决了这个问题。这项工作的正确工具是axis,axis-wsdl4j。

于 2013-11-19T08:17:49.317 回答