2017-03-31 51 views
0

我一直在嘗試使用澤西2.25.1編寫下面的代碼,但我不知道要在實體中傳遞什麼。有人可以幫我弄清楚,因爲沒有實體和球衣2.25.1後期方法需要實體考慮哪個實體和媒體類型。用球衣1.13使用澤西2.25.1設置ByteArrayInputStream後處理方法2.25.1

WebResource resourceGetToken = client.createResource(ESignatureSpringUtil.getMessage(KeyConstants.ALSB_DOCUSIGN_ADDRESS) 
          + ESignatureSpringUtil.getMessage(KeyConstants.REST_GET_TOKEN_ADDRESS)); 

        ClientResponse tokenResponse = resourceGetToken 
         .header(KeyConstants.REST_URI_APPENDERS, tokenSb) 
         .header(DocusignRESTContants.CONTENT_TYPE, DocusignRESTContants.APPLICATION_XML) 
         .header(DocusignRESTContants.X_DOCUSIGN_AUTHENTICATION, getDocusignAuthHeader(cu)) 
         .accept(MediaType.APPLICATION_XML) 
         .post(ClientResponse.class, new ByteArrayInputStream(tokenStream.toString().getBytes())); 

        if (tokenResponse.getStatus() == 200) { 
         RetrieveTokenResponse tokenResp = (RetrieveTokenResponse) tokenResponse.getEntity(RetrieveTokenResponse.class); 

新澤西2.25.1

WebTarget resourceGetToken = client.createResource(ESignatureSpringUtil.getMessage(KeyConstants.ALSB_DOCUSIGN_ADDRESS) 
          + ESignatureSpringUtil.getMessage(KeyConstants.REST_GET_TOKEN_ADDRESS)); 

        Invocation.Builder invcocationBuilder = resourceGetToken.request() 
          .header(KeyConstants.REST_URI_APPENDERS, tokenSb) 
          .header(DocusignRESTContants.CONTENT_TYPE, DocusignRESTContants.APPLICATION_XML) 
          .header(DocusignRESTContants.X_DOCUSIGN_AUTHENTICATION, getDocusignAuthHeader(cu)) 
          .accept(MediaType.APPLICATION_XML); 

        Response tokenResponse = invcocationBuilder.post(Entity.entity(entity, mediaType)); 

現有的代碼,我需要得到字節流和重載後的方法不允許我這樣做。

謝謝

回答

0

這就是我如何做到這一點。

Response response = builder.put(Entity.entity(new ByteArrayInputStream(jsonObj.toString().getBytes()), MediaType.APPLICATION_XML), Response.class);