2

我尝试通过RESTweb 服务将简单的图像上传到 jasper 服务器。

这是 HTTP 请求/响应,我收到"400 Bad Request: Invalid resource descriptor"。我试图从存储库中复制一个有效的资源描述符并重新上传它,但它给出了同样的错误!

(点代表\r\n\t字符。)

T 10.84.6.166:36057 -> 10.84.6.166:8080 [AP].
PUT /jasperserver/rest/resource/reports/Customers/3221/image01.gif HTTP/1.1.
User-Agent: useragent.
Host: 10.84.6.166:8080.
Accept: */*.
Cookie: JSESSIONID=5D8D24835E61ED65ABD982964243C06B.
Content-Type: multipart/form-data; boundary="72e01e9922f8bb1669638258c2a2a155".
Content-Length: 23796.
Expect: 100-continue.
.


T 10.84.6.166:8080 -> 10.84.6.166:36057 [AP]
HTTP/1.1 100 Continue.
.


T 10.84.6.166:36057 -> 10.84.6.166:8080 [AP]
--72e01e9922f8bb1669638258c2a2a155.
Content-Disposition: form-data; name="ResourceDescriptor".
Content-Length: 811.
Content-Type: text/plain; charset=UTF-8.
Content-Transfer-Encoding: 8bit.
.
<resourceDescriptor name="s2" wsType="img" uriString="/reports/Customers/3221/s2.png" isNew="true">.
.<label><![CDATA[serverattacks_13-06-01.png]]></label>.
.<creationDate>1373470272965</creationDate>.
.<resourceProperty name="PROP_RESOURCE_TYPE">.
..<value><![CDATA[com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource]]></value>.
.</resourceProperty>.
.<resourceProperty name="PROP_PARENT_FOLDER">.
..<value><![CDATA[/reports/Customers/3221]]></value>.
.</resourceProperty>.
.<resourceProperty name="PROP_VERSION">.
..<value><![CDATA[0]]></value>.
.</resourceProperty>.
.<resourceProperty name="PROP_HAS_DATA">.
..<value><![CDATA[true]]></value>.
.</resourceProperty>.
.<resourceProperty name="PROP_IS_REFERENCE">.
..<value><![CDATA[false]]></value>.
.</resourceProperty>.
</resourceDescriptor>.
--72e01e9922f8bb1669638258c2a2a155.
Content-Disposition: form-data; name="/reports/Customers/3221/s2.png".
Content-Length: 22544.
Content-Type: application/octet-stream.
Content-Transfer-Encoding: binary.
.
<long binary png contents>
--72e01e9922f8bb1669638258c2a2a155--.


T 10.84.6.166:8080 -> 10.84.6.166:36057 [AP]
HTTP/1.1 400 Bad Request.
Server: Apache-Coyote/1.1.
Pragma: No-cache.
Cache-Control: no-cache.
Expires: Thu, 01 Jan 1970 01:00:00 CET.
P3P: CP="ALL".
Content-Type: text/xml;charset=UTF-8.
Content-Length: 27.
Date: Thu, 11 Jul 2013 08:42:09 GMT.
Connection: close.
.
Invalid resource descriptor

更新:

我仍然不知道出了什么问题,但我终于让它工作并在 github 上发布了一个 Jasper PHP 库:http: //blog.flowl.info/2013/jasper-php-library-on-github/

4

1 回答 1

2

我试图在 jasperServer 上更新 jrxml。我发现并构建了 java 测试。我找到了在 JasperServer 上更新图像的工作示例。可能对你有帮助。(在这个示例的帮助下,我写了更新 jasperServer 上的 jrxml 的请求。它是有效的!)

    POST http://repsuite.cheby.ru:8080/jasperserver/rest/resource/SAMPLE_REST_FOLDER/JUNIT_IMAGE_FILE HTTP/1.1
Content-Length: 5560
Content-Type: multipart/form-data; boundary=dzFSpJmyJB0pL6bHxKgtqI4VmaKgL9pTWCrLeJv
Host: repsuite.cheby.ru:8080
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Cookie: JSESSIONID=E485652B97C69549403D8CEEA0DC0855
Cookie2: $Version=1

--dzFSpJmyJB0pL6bHxKgtqI4VmaKgL9pTWCrLeJv
Content-Disposition: form-data; name="ResourceDescriptor"

<resourceDescriptor name="JUNIT_IMAGE_FILE" wsType="img" uriString="/SAMPLE_REST_FOLDER/JUNIT_IMAGE_FILE" isNew="true">
    <label>jaspersoft logo</label>
    <description>jaspersoft logo</description>
    <creationDate>1308696383000</creationDate>
    <resourceProperty name="PROP_RESOURCE_TYPE">
        <value>com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource</value>
    </resourceProperty>
    <resourceProperty name="PROP_PARENT_FOLDER">
        <value>/SAMPLE_REST_FOLDER</value>
    </resourceProperty>
    <resourceProperty name="PROP_VERSION">
        <value>0</value>
    </resourceProperty>
    <resourceProperty name="PROP_IS_REFERENCE">
        <value>false</value>
    </resourceProperty>
    <resourceProperty name="PROP_HAS_DATA">
        <value>true</value>
    </resourceProperty>
</resourceDescriptor>
--dzFSpJmyJB0pL6bHxKgtqI4VmaKgL9pTWCrLeJv
Content-Disposition: form-data; name="/SAMPLE_REST_FOLDER/JUNIT_IMAGE_FILE"; filename="jasperSoftLogo_2.jpg"
Content-Type: application/octet-stream

----图片的二进制内容----

于 2013-07-23T12:05:14.040 回答