简体   繁体   English

如何通过代理重定向javax.ws.rs.client.WebTarget Post请求

[英]How to redirect a javax.ws.rs.client.WebTarget Post request via a Proxy

I have an a server that is trying to make a POST call to an external IP, unfortunately if I make the call directly it is blocked by an internal firewall. 我有一台服务器正在尝试对外部IP进行POST调用,不幸的是,如果我直接进行该调用,则它被内部防火墙阻止。

However we do have a proxy that allowed outbound http traffic, if I redirect the POST call via this proxy first, then it should succeed. 但是,我们确实有一个允许出站http流量的代理,如果我首先通过该代理重定向POST调用,那么它应该会成功。

The client making the call is using a javax.ws.rs.client.WebTarget object to create/direct the POST in the call format: 进行呼叫的客户端使用javax.ws.rs.client.WebTarget对象以呼叫格式创建/定向POST:

WebTarget.path("URL_HERE").request().post(ENTITY_HERE).readEntity(RETURN_TYPE_HERE.class);

However I can see no way in the javax ws documentaton to redirect this call via the proxy (for instance via host = proxy_domain, and port = 1). 但是我看不到javax ws文档中通过代理重定向此调用的方法(例如,通过host = proxy_domain和port = 1)。

Secondly is there a way to scope the proxy redirection? 其次,有没有办法确定代理重定向的范围? For instance I can see some similar documentation online regarding updating a wsdl for global settings - but I only wish for this to happen for this single POST call. 例如,我可以在网上看到一些有关为全局设置更新wsdl的类似文档-但我只希望在单个POST调用中做到这一点。

EDIT: This Q is the same as an earlier one regarding the proxy call, though the answer to that one did not suffice - I have added a note to the comments here on the addition of the ApacheConnectorProvider that was required to get the 'via' call instantiated. 编辑:此Q与关于代理调用的较早版本相同,尽管对该问题的答案并不足够-我在此处的注释中添加了注释,以获取获得“ via”所需的ApacheConnectorProvider的添加调用实例化。

The solution as mentioned there was to create config as per: 那里提到的解决方案是按照以下步骤创建配置:

ClientConfig config = new ClientConfig().connectorProvider(new ApacheConnectorProvider()) .property(ClientProperties.PROXY_URI, "http://PROXY_ADDRESS:PROXY_PORT");

Using Jersey 2.27. 使用泽西岛2.27。

Answer was as per 答案是按照

Proxy setting not working in Jersey ClientConfig 代理设置在Jersey ClientConfig中不起作用

I have added the code segment I needed to the end of my original question. 我已经在原始问题的末尾添加了所需的代码段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 javax.ws.rs.client.WebTarget 可选查询参数 - javax.ws.rs.client.WebTarget optional queryparam 使用 javax.ws.rs.client.WebTarget 设置连接超时 - Set connection time out with javax.ws.rs.client.WebTarget javax.ws.rs.client.WebTarget POST并同时获得响应 - javax.ws.rs.client.WebTarget POST and get Response in the same time 如何使用javax.ws.rs.client.WebTarget从REST客户端发送json对象 - how to send json object from REST client using javax.ws.rs.client.WebTarget 如何检查通过RESTful客户端(javax.ws.rs.client)发送到restful webservice的exacly请求 - how to check what exacly request i send to restful webservice via restful client (javax.ws.rs.client) javax.ws.rs.client.Client 如何配置readTimeOut? - javax.ws.rs.client.Client how to configure readTimeOut? 如何使用javax.ws.rs将post端点放在请求体中数据传递的位置? - How make post endpoint where data pass in request body using javax.ws.rs? javax.ws.rs.client.Entity如何将对象序列化为json? - How is javax.ws.rs.client.Entity serializing objects to json? 重用 javax.ws.rs.client.Client - Reusing javax.ws.rs.client.Client 在使用 Javax webtarget 客户端发送 HTTPS 请求时,如何避免对包含“:[”的查询参数进行编码? - In sending HTTPS request using Javax webtarget client, how to avoid encoding of query params that contain ":["?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM