Upload report unit via webservice in C# .net to jasperserver

允我心安 提交于 2019-11-27 16:50:22

问题


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!


回答1:


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!



来源:https://stackoverflow.com/questions/4351511/upload-report-unit-via-webservice-in-c-sharp-net-to-jasperserver

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!