WSAddressingFeature feature = new WSAddressingFeature(); if (addressingRequired(bindingExtensors) || addressingRequired(portExtensors)) {
public final void resolveFeatures() { AddressingFeature addressing = getAddressingFeature(); if (addressing == null) { return; } if (addressing.isEnabled()) { WSAddressingFeature feature = getWSAddressingFeature(); if (feature == null) { feature = new WSAddressingFeature(); addAddressingFeature(feature); } feature.setAddressingRequired(addressing.isRequired()); feature.setResponses(addressing.getResponses().toString()); } else { removeAddressingFeature(); getEndpointInfo().setProperty("org.apache.cxf.ws.addressing.MAPAggregator.addressingDisabled", Boolean.TRUE); } }
WSAddressingFeature wsAddressingFeature = new WSAddressingFeature(); wsAddressingFeature.initialize(client, client.getBus());
public Endpoint createEndpoint() throws BusException, EndpointException { Endpoint ep = super.createEndpoint(); new WSAddressingFeature().initialize(ep, getBus()); return ep; } }
public Endpoint createEndpoint() throws BusException, EndpointException { Endpoint ep = super.createEndpoint(); new WSAddressingFeature().initialize(ep, getBus()); return ep; } }
/** * {@inheritDoc} * * @see org.jboss.wise.core.wsextensions.EnablerDelegate#visitWSAddressing(Object) */ public void visitWSAddressing(Object endpointInstance) throws UnsupportedOperationException { Bus bus = BusFactory.getThreadDefaultBus(); Client client = ClientProxy.getClient(endpointInstance); WSAddressingFeature feature = new WSAddressingFeature(); feature.initialize(client, bus); }
factory.setServiceClass(...); factory.setAddress(...); factory.getFeatures().add(new WSAddressingFeature()); SomePortType client = (SomePortType) factory.create(); AddressingProperties maps = new AddressingPropertiesImpl(); EndpointReferenceType epr = new EndpointReferenceType(); //Then you can add referenceParameters to the epr ReferenceParametersType ref = new ReferenceParametersType(); List<Object> paras = ref.getAny(); Country ctry = new Country("xx"); JAXBContext ctx = JAXBContext.newInstance(new Class[] {Country.class }); Marshaller marshaller = ctx.createMarshaller(); DOMResult res = new DOMResult(); marshaller.marshal(ctry, res); Element elt = ((Document) res.getNode()).getDocumentElement(); any.add(elt); epr.setReferenceParameters(ref); maps.setTo(epr); ((BindingProvider)client).getRequestContext() .put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, maps);
/** * Initialize JAXWS proxy factory bean * @param factory JAXWS Proxy factory bean */ public void initializeFactory(JaxWsProxyFactoryBean factory) { // set outgoing security (username/password) if (StringUtils.isNotEmpty(getHttpUser())) { factory.setUsername(getHttpUser()); factory.setPassword(getHttpPassword()); } // enable WS-addressing if (StringUtils.isNotEmpty(getWSAddressingToUri())) { factory.getFeatures().add(new WSAddressingFeature()); } }
private void configureService(ServerFactoryBean svrFactory, Object service) { svrFactory.setServiceClass(wsTransactionConfiguration.getSei()); svrFactory.setServiceName(wsTransactionConfiguration.getServiceName()); svrFactory.setWsdlLocation(wsTransactionConfiguration.getWsdlLocation()); svrFactory.setAddress(serviceAddress); svrFactory.setServiceBean(service); svrFactory.getFeatures().add(new WSAddressingFeature()); if (wsTransactionConfiguration.isMtom()) { svrFactory.setProperties(Collections.singletonMap("mtom-enabled", "true")); } }
/** * Creates a charging station web service proxy. * * @param chargingStationAddress address of the charging station. * @return charging station web service proxy */ public ChargePointService createChargingStationService(String chargingStationAddress) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(ChargePointService.class); factory.setAddress(chargingStationAddress); SoapBindingConfiguration conf = new SoapBindingConfiguration(); conf.setVersion(Soap12.getInstance()); factory.setBindingConfig(conf); factory.getFeatures().add(new WSAddressingFeature()); ChargePointService chargePointService = (ChargePointService) factory.create(); //Force the use of the Async transport, even for synchronous calls ((BindingProvider) chargePointService).getRequestContext().put("use.async.http.conduit", Boolean.TRUE); return chargePointService; }
/** * Creates a vas subscriber web service proxy based on the delivery address. * * @param deliveryAddress delivery address * @return subscriber web service proxy */ public VasSubscriberService createVasSubscriberService(String deliveryAddress) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(VasSubscriberService.class); factory.setAddress(deliveryAddress); SoapBindingConfiguration conf = new SoapBindingConfiguration(); conf.setVersion(Soap12.getInstance()); factory.setBindingConfig(conf); factory.getFeatures().add(new WSAddressingFeature()); VasSubscriberService vasSubscriberService = (VasSubscriberService) factory.create(); //Force the use of the Async transport, even for synchronous calls ((BindingProvider) vasSubscriberService).getRequestContext().put("use.async.http.conduit", Boolean.TRUE); return vasSubscriberService; }
/** * Creates a charging station web service proxy. * * @param chargingStationAddress address of the charging station. * @return charging station web service proxy */ public ChargePointService createChargingStationService(String chargingStationAddress) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(ChargePointService.class); factory.setAddress(chargingStationAddress); SoapBindingConfiguration conf = new SoapBindingConfiguration(); conf.setVersion(Soap12.getInstance()); factory.setBindingConfig(conf); factory.getFeatures().add(new WSAddressingFeature()); ChargePointService chargePointService = (ChargePointService) factory.create(); //Force the use of the Async transport, even for synchronous calls ((BindingProvider) chargePointService).getRequestContext().put("use.async.http.conduit", Boolean.TRUE); return chargePointService; }
protected void run() { faultToserver = new org.eclipse.jetty.server.Server(Integer.parseInt(FAULT_PORT)); faultToserver.setHandler(new HelloHandler()); try { faultToserver.start(); } catch (Exception e) { e.printStackTrace(); } setBus(BusFactory.getDefaultBus()); Object implementor = new AddNumberImpl(); String address = "http://localhost:" + PORT + "/jaxws/add"; ep = (EndpointImpl) Endpoint.create(implementor); ep.getInInterceptors().add(new DecoupledFaultHandler()); ep.getFeatures().add(new WSAddressingFeature()); ep.publish(address); Object implementor2 = new GreeterImpl(); String address2 = "http://localhost:" + PORT + "/jaxws/greeter"; ep = (EndpointImpl) Endpoint.create(implementor2); ep.getInInterceptors().add(new DecoupledFaultHandler()); ep.getFeatures().add(new WSAddressingFeature()); ep.publish(address2); }
protected void run() { setBus(BusFactory.getDefaultBus()); Object implementor = new AddNumberImpl(); String address = "http://localhost:" + PORT + "/jaxws/add"; //Endpoint.publish(address, implementor); ep = (EndpointImpl) Endpoint.create(implementor); ep.getFeatures().add(new WSAddressingFeature()); ep.publish(address); ep = new EndpointImpl(BusFactory.getThreadDefaultBus(), implementor, null, getWsdl()); ep.setServiceName(new QName("http://apache.org/cxf/systest/ws/addr_feature/", "AddNumbersService")); ep.setEndpointName(new QName("http://apache.org/cxf/systest/ws/addr_feature/", "AddNumbersNonAnonPort")); String address12 = "http://localhost:" + PORT2 + "/jaxws/soap12/add"; ep.getFeatures().add(new WSAddressingFeature()); ep.publish(address12); }
@Test public void testCxfWsaFeature() throws Exception { ByteArrayOutputStream input = setupInLogging(); ByteArrayOutputStream output = setupOutLogging(); JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(AddNumbersPortType.class); factory.setAddress("http://localhost:" + PORT + "/jaxws/add"); factory.getFeatures().add(new WSAddressingFeature()); AddNumbersPortType port = (AddNumbersPortType) factory.create(); ((BindingProvider)port).getRequestContext().put("ws-addressing.write.optional.replyto", Boolean.TRUE); assertEquals(3, port.addNumbers(1, 2)); assertLogContains(output.toString(), "//wsa:Address", "http://www.w3.org/2005/08/addressing/anonymous"); assertLogContains(input.toString(), "//wsa:RelatesTo", getLogValue(output.toString(), "//wsa:MessageID")); }
@Test public void testEchoProviderAsyncDecoupledEndpoints() throws Exception { String requestString = "<echo/>"; Service service = Service.create(serviceName); service.addPort(fakePortName, javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING, "http://localhost:" + PORT + "/SoapContext/AsyncEchoProvider"); Dispatch<StreamSource> dispatcher = service.createDispatch(fakePortName, StreamSource.class, Service.Mode.PAYLOAD, new LoggingFeature()); Client client = ((DispatchImpl<StreamSource>)dispatcher).getClient(); WSAddressingFeature wsAddressingFeature = new WSAddressingFeature(); wsAddressingFeature.initialize(client, client.getBus()); dispatcher.getRequestContext().put("org.apache.cxf.ws.addressing.replyto", "http://localhost:" + CLIENT_PORT + "/SoapContext/AsyncEchoClient"); StreamSource request = new StreamSource(new ByteArrayInputStream(requestString.getBytes())); StreamSource response = dispatcher.invoke(request); assertEquals(requestString, StaxUtils.toString(response)); } }
@Test public void testClientProxyFactory() { JaxWsProxyFactoryBean cf = new JaxWsProxyFactoryBean(); cf.setAddress("http://localhost:" + PORT + "/test"); cf.getFeatures().add(new WSAddressingFeature()); cf.setServiceClass(Greeter.class); Greeter greeter = (Greeter) cf.create(); Client client = ClientProxy.getClient(greeter); checkAddressInterceptors(client.getInInterceptors()); }
public final void resolveFeatures() { AddressingFeature addressing = getAddressingFeature(); if (addressing == null) { return; } if (addressing.isEnabled()) { WSAddressingFeature feature = getWSAddressingFeature(); if (feature == null) { feature = new WSAddressingFeature(); addAddressingFeature(feature); } feature.setAddressingRequired(addressing.isRequired()); feature.setResponses(addressing.getResponses().toString()); } else { removeAddressingFeature(); getEndpointInfo().setProperty("org.apache.cxf.ws.addressing.MAPAggregator.addressingDisabled", Boolean.TRUE); } }
protected void run() { setBus(BusFactory.getDefaultBus()); Object implementor = new AddNumberImpl(); String address = "http://localhost:" + PORT + "/AddNumberImplPort"; ep1 = new EndpointImpl(implementor); ep1.getFeatures().add(new WSAddressingFeature()); ep1.publish(address); ep2 = new EndpointImpl(new AddNumberImplNoAddr()); ep2.publish(address + "-noaddr"); } public void tearDown() {
@Test public void testServerFactory() { JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean(); sf.getFeatures().add(new WSAddressingFeature()); sf.setServiceBean(new GreeterImpl()); sf.setAddress("http://localhost:" + PORT + "/test"); sf.setStart(false); sf.setBus(getBus()); Server server = sf.create(); Endpoint endpoint = server.getEndpoint(); checkAddressInterceptors(endpoint.getInInterceptors()); }