2
有沒有辦法強制Apache CXF使用特定的網絡適配器?使用所需的網絡適配器撥打網絡服務
我已經使用Jax-WS生成了soap web服務代理類,並使用下面的代碼調用服務。我只想通過使用無線網絡適配器調用服務而不禁用有線以太網連接。在系統
FooService oServ = new FooWSService();
FooWS oWs = oServ.getFooWSPort();
String endpointURL = "https://fooservice/serviceWSPort";
BindingProvider bindingProvider = (BindingProvider) oWs;
Map<String, Object> requestContext = bindingProvider.getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
org.apache.cxf.endpoint.Client client = ClientProxy.getClient(oWs);
org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
String result = oWS.TestMethod();
Avaible網絡適配器使用
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
結果:
Display name: Realtek PCIe GBE Family Controller
Name: eth4
InetAddress: /fe80:0:0:0:914b:ee4a:58b7:e5b3%12
InetAddress: /10.10.10.227
Display name: 1x1 11b/g/n Wireless LAN PCI Express Half Mini Card Adapter
Name: net4
InetAddress: /fe80:0:0:0:513:7a5a:d3ab:9278%13
InetAddress: /10.10.11.35