我一直试图使用jersey2.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方法不允许我这样做。
谢谢
发布于 2017-03-31 17:26:22
我就是这样做的。
Response response = builder.put( Entity.entity( new ByteArrayInputStream( jsonObj.toString().getBytes() ), MediaType.APPLICATION_XML ), Response.class );https://stackoverflow.com/questions/43143274
复制相似问题