我一直在尝试使用jersey 2.25.1编写以下代码,但我不确定在实体中传递什么。有人可以帮我解决这个问题,因为没有实体,并且在球衣2.25.1中,post方法将实体考虑到哪个实体和媒体类型。
现有代码使用jersey 1.13
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));
我需要获取字节流,重载的post方法不允许我这样做。
由于
答案 0 :(得分:0)
这就是我这样做的方式。
Response response = builder.put( Entity.entity( new ByteArrayInputStream( jsonObj.toString().getBytes() ), MediaType.APPLICATION_XML ), Response.class );