[英]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.