2017-03-31 69 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);