通过C#.net中的webservice上传报告单元到jasperserver

发布于 2024-10-06 07:35:43 字数 1952 浏览 7 评论 0原文

我正在尝试通过 C# .net 的 Web 服务将新的报告单元上传到 jasperserver 我已成功上传/创建了报告单元,但是当我通过 iReport 存储库导航器单击报告时,它显示“没有附件!”在弹出框中。下面是我发送到 Web 服务的“createXML”:

    <request operationName='put' locale='en'>
          <resourceDescriptor name='barunit' wsType='reportUnit'
             uriString='/reports/bar/bar_files'
             isNew='true'>
            <label>Bar Unit</label>
            <description>This is a test</description>
            <resourceProperty name='PROP_PARENT_FOLDER'>
                <value>/reports/bar</value>
            </resourceProperty>

            <resourceDescriptor name='bar.jrxml' wsType='jrxml'
                 uriString='/reports/bar/bar_files'
                 isNew='true'>
                <label>Bar Report</label>
                <description>This is a test</description>

                <resourceProperty name='PROP_RU_IS_MAIN_REPORT'>
                    <value>true</value>
                </resourceProperty>
           </resourceDescriptor>
       </resourceDescriptor>
    </request>

下面是将“createXML”发送到 Web 服务的代码:

JasperService.ManagementServiceService service = new JasperService.ManagementServiceService();
        service.Credentials = new System.Net.NetworkCredential("jasperadmin", "jasperadmin");
        service.PreAuthenticate = true; 

FileStream fs = new FileStream(@"C:\bar.jrxml", FileMode.Open, FileAccess.Read);


        Microsoft.Web.Services2.Attachments.Attachment jrxmlAttachment = new Microsoft.Web.Services2.Attachments.Attachment("text/xml",fs);

        service.RequestSoapContext.Attachments.Add(jrxmlAttachment);
        string out = service.put(createXML);

Web 服务调用的响应给出了成功代码“0”,所以我有点困惑。我猜问题出在 RequestSoapContext 的文件附件中,因为在此之前一切都已追踪完毕。

任何帮助将不胜感激!

I'm trying to upload a new report unit to the jasperserver via the webservice from C# .net I've successfully uploaded/created the report unit but when I click on the report via the iReport repository navigator it says "No Attachment Present!" in a popup box. Below is the 'createXML' I'm sending to the webservice:

    <request operationName='put' locale='en'>
          <resourceDescriptor name='barunit' wsType='reportUnit'
             uriString='/reports/bar/bar_files'
             isNew='true'>
            <label>Bar Unit</label>
            <description>This is a test</description>
            <resourceProperty name='PROP_PARENT_FOLDER'>
                <value>/reports/bar</value>
            </resourceProperty>

            <resourceDescriptor name='bar.jrxml' wsType='jrxml'
                 uriString='/reports/bar/bar_files'
                 isNew='true'>
                <label>Bar Report</label>
                <description>This is a test</description>

                <resourceProperty name='PROP_RU_IS_MAIN_REPORT'>
                    <value>true</value>
                </resourceProperty>
           </resourceDescriptor>
       </resourceDescriptor>
    </request>

And here is the code that sends 'createXML' to the webservice:

JasperService.ManagementServiceService service = new JasperService.ManagementServiceService();
        service.Credentials = new System.Net.NetworkCredential("jasperadmin", "jasperadmin");
        service.PreAuthenticate = true; 

FileStream fs = new FileStream(@"C:\bar.jrxml", FileMode.Open, FileAccess.Read);


        Microsoft.Web.Services2.Attachments.Attachment jrxmlAttachment = new Microsoft.Web.Services2.Attachments.Attachment("text/xml",fs);

        service.RequestSoapContext.Attachments.Add(jrxmlAttachment);
        string out = service.put(createXML);

The response from the webservice call gives the success code '0' so I'm sort of stumped. I'm guessing the trouble is in the file attachment to the RequestSoapContext because everything traces out well before that.

Any help would be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-10-13 07:35:43

我缺少一些标签:CREATE_REPORTUNIT_BOOLEAN、PROP_HAS_DATA 和 PROP_PARENT_FOLDER。

下面是最终的请求 xml,它允许我通过 Web 服务上传报告单元。调用该服务的 C# 与原始问题相比没有变化。

<request operationName='put' locale='en'>
    <argument name='CREATE_REPORTUNIT_BOOLEAN'>true</argument>
    <resourceDescriptor name='barunit' wsType='reportUnit'
         uriString='/reports/bar/bar_files'
         isNew='true'>
      <label>Bar Unit</label>
      <description>This is a test</description>
      <resourceProperty name='PROP_PARENT_FOLDER'>
        <value>/reports/bar</value>
      </resourceProperty>

      <resourceDescriptor name='bar.jrxml' wsType='jrxml'
          uriString='/reports/bar/bar_files'
          isNew='true'>
        <label>Bar Report</label>
        <description>This is a test</description>

        <resourceProperty name='PROP_RU_IS_MAIN_REPORT'>
          <value>true</value>
        </resourceProperty>
        <resourceProperty name='PROP_HAS_DATA'>
          <value><![CDATA[true]]></value>
        </resourceProperty>
        <resourceProperty name='PROP_PARENT_FOLDER'>
          <value>/reports/testunit_files</value>
        </resourceProperty>
      </resourceDescriptor>
    </resourceDescriptor>
</request>

希望能帮助那里的人!

I was missing a few tags: CREATE_REPORTUNIT_BOOLEAN, PROP_HAS_DATA, and PROP_PARENT_FOLDER.

Below is the final request xml that allowed me to upload the report unit via the webservice. The C# that calls the service didn't change from the original question.

<request operationName='put' locale='en'>
    <argument name='CREATE_REPORTUNIT_BOOLEAN'>true</argument>
    <resourceDescriptor name='barunit' wsType='reportUnit'
         uriString='/reports/bar/bar_files'
         isNew='true'>
      <label>Bar Unit</label>
      <description>This is a test</description>
      <resourceProperty name='PROP_PARENT_FOLDER'>
        <value>/reports/bar</value>
      </resourceProperty>

      <resourceDescriptor name='bar.jrxml' wsType='jrxml'
          uriString='/reports/bar/bar_files'
          isNew='true'>
        <label>Bar Report</label>
        <description>This is a test</description>

        <resourceProperty name='PROP_RU_IS_MAIN_REPORT'>
          <value>true</value>
        </resourceProperty>
        <resourceProperty name='PROP_HAS_DATA'>
          <value><![CDATA[true]]></value>
        </resourceProperty>
        <resourceProperty name='PROP_PARENT_FOLDER'>
          <value>/reports/testunit_files</value>
        </resourceProperty>
      </resourceDescriptor>
    </resourceDescriptor>
</request>

Hope that helps somebody out there!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文