我正在尝试通过来自C#.net的网络服务将新报告单元上传到jasperserver我已成功上传/创建了报告单元,但当我通过iReport资源库导航器点击报告时,它显示“无附件”当下!”在一个弹出框中。下面是我发送给webservice的'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'发送到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);
来自webservice调用的响应给出了成功代码'0',所以我有点难过。我猜测问题出在RequestSoapContext的文件附件中,因为在此之前一切都很好。
非常感谢任何帮助!
答案 0 :(得分:5)
我遗漏了一些标签:CREATE_REPORTUNIT_BOOLEAN,PROP_HAS_DATA和PROP_PARENT_FOLDER。
以下是允许我通过网络服务上传报告单元的最终请求xml。调用该服务的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>
希望能帮到那里的人!