pdf文件是85 kb的简单发票错误是状态代码414,它是“ Uri太长”]
调试原始的亚马逊类MarketplaceWebServiceClient,我看到了:
if( request instanceof SubmitFeedRequest ) {
// For SubmitFeed, HTTP body is reserved for the Feed Content and the function parameters
// are contained within the HTTP header
SubmitFeedRequest sfr = (SubmitFeedRequest)request;
method = new HttpPost( config.getServiceURL() + "?" + getSubmitFeedUrlParameters( parameters ) );
getSubmitFeedUrlParameters方法获取每个参数,并将其添加到querystring。这些参数之一是来自以下位置的contentMD5:字符串contentMD5 = Base64.encodeBase64String(pdfDocument);因此,有一个很大的字符串表示作为参数传递的pdf文件。这导致错误414
但是该类是来自MaWSJavaClientLibrary-1.1.jar的原始类。>
有人可以帮我吗?
谢谢
我正在按照本指南中的Java示例通过_UPLOAD_VAT_INVOICE_将发票发送给亚马逊MWS:链接pdf文件是85 kb的简单发票,错误是状态码414,即“ Uri ...
InputStream contentStream = new ByteArrayInputStream(pdfDocument);
String contentMD5 =computeContentMD5Header(new ByteArrayInputStream(pdfDocument));
public static String computeContentMD5Header(InputStream inputStream) {
// Consume the stream to compute the MD5 as a side effect.
DigestInputStream s;
try {
s = new DigestInputStream(inputStream,
MessageDigest.getInstance("MD5"));
// drain the buffer, as the digest is computed as a side-effect
byte[] buffer = new byte[8192];
while (s.read(buffer) > 0)
;
return new String(
org.apache.commons.codec.binary.Base64.encodeBase64(s
.getMessageDigest().digest()), "UTF-8");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}