Java Code Examples for org.apache.cxf.endpoint.Endpoint#getBinding()
The following examples show how to use
org.apache.cxf.endpoint.Endpoint#getBinding() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MAPAggregatorTest.java From cxf with Apache License 2.0 | 6 votes |
private void setUpRebase(Message message, Exchange exchange, Endpoint endpoint) throws Exception { setUpMessageProperty(message, "org.apache.cxf.ws.addressing.partial.response.sent", Boolean.FALSE); Binding binding = control.createMock(Binding.class); endpoint.getBinding(); EasyMock.expectLastCall().andReturn(binding).anyTimes(); Message partialResponse = getMessage(); binding.createMessage(EasyMock.isA(Message.class)); EasyMock.expectLastCall().andReturn(partialResponse); Destination target = control.createMock(Destination.class); setUpMessageDestination(message, target); Conduit backChannel = control.createMock(Conduit.class); target.getBackChannel(EasyMock.eq(message)); EasyMock.expectLastCall().andReturn(backChannel); // REVISIT test interceptor chain setup & send }
Example 2
Source File: ProviderServiceFactoryTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testFromWSDL() throws Exception { URL resource = getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(resource); JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(HWSoapMessageProvider.class); JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean(implInfo); bean.setWsdlURL(resource.toString()); Bus bus = getBus(); bean.setBus(bus); bean.setServiceClass(HWSoapMessageProvider.class); Service service = bean.create(); assertTrue(service.getInvoker() instanceof JAXWSMethodInvoker); assertEquals("SOAPService", service.getName().getLocalPart()); assertEquals("http://apache.org/hello_world_soap_http", service.getName().getNamespaceURI()); InterfaceInfo intf = service.getServiceInfos().get(0).getInterface(); assertNotNull(intf); JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); svrFactory.setBus(bus); svrFactory.setServiceFactory(bean); svrFactory.setStart(false); ServerImpl server = (ServerImpl)svrFactory.create(); assertTrue(server.getEndpoint().getService().getInvoker() instanceof JAXWSMethodInvoker); Endpoint endpoint = server.getEndpoint(); Binding binding = endpoint.getBinding(); assertTrue(binding instanceof SoapBinding); }
Example 3
Source File: ProviderServiceFactoryTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testXMLBindingFromCode() throws Exception { JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean(); bean.setServiceClass(DOMSourcePayloadProvider.class); bean.setBus(getBus()); bean.setInvoker(new JAXWSMethodInvoker(new DOMSourcePayloadProvider())); Service service = bean.create(); assertEquals("DOMSourcePayloadProviderService", service.getName().getLocalPart()); InterfaceInfo intf = service.getServiceInfos().get(0).getInterface(); assertNotNull(intf); JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); svrFactory.setBus(getBus()); svrFactory.setServiceFactory(bean); String address = "http://localhost:9000/test"; svrFactory.setAddress(address); svrFactory.setTransportId(LocalTransportFactory.TRANSPORT_ID); ServerImpl server = (ServerImpl)svrFactory.create(); assertEquals(1, service.getServiceInfos().get(0).getEndpoints().size()); Endpoint endpoint = server.getEndpoint(); Binding binding = endpoint.getBinding(); assertTrue(binding instanceof XMLBinding); Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/provider/sayHi.xml"); addNamespace("j", "http://service.jaxws.cxf.apache.org/"); assertValid("/j:sayHi", res); }
Example 4
Source File: ProviderServiceFactoryTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testSOAPBindingFromCode() throws Exception { JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean(); bean.setServiceClass(SOAPSourcePayloadProvider.class); bean.setBus(getBus()); bean.setInvoker(new JAXWSMethodInvoker(new SOAPSourcePayloadProvider())); Service service = bean.create(); assertEquals("SOAPSourcePayloadProviderService", service.getName().getLocalPart()); InterfaceInfo intf = service.getServiceInfos().get(0).getInterface(); assertNotNull(intf); assertEquals(1, intf.getOperations().size()); JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); svrFactory.setBus(getBus()); svrFactory.setServiceFactory(bean); String address = "local://localhost:9000/test"; svrFactory.setAddress(address); ServerImpl server = (ServerImpl)svrFactory.create(); // See if our endpoint was created correctly assertEquals(1, service.getServiceInfos().get(0).getEndpoints().size()); Endpoint endpoint = server.getEndpoint(); Binding binding = endpoint.getBinding(); assertTrue(binding instanceof SoapBinding); SoapBindingInfo sb = (SoapBindingInfo)endpoint.getEndpointInfo().getBinding(); assertEquals("document", sb.getStyle()); assertFalse(bean.isWrapped()); assertEquals(1, sb.getOperations().size()); Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/sayHi.xml"); addNamespace("j", "http://service.jaxws.cxf.apache.org/"); assertValid("/s:Envelope/s:Body/j:sayHi", res); }
Example 5
Source File: ProviderServiceFactoryTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testSAAJProviderCodeFirst() throws Exception { JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean(); bean.setServiceClass(SAAJProvider.class); bean.setBus(getBus()); bean.setInvoker(new JAXWSMethodInvoker(new SAAJProvider())); Service service = bean.create(); assertEquals("SAAJProviderService", service.getName().getLocalPart()); InterfaceInfo intf = service.getServiceInfos().get(0).getInterface(); assertNotNull(intf); assertEquals(1, intf.getOperations().size()); JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); svrFactory.setBus(getBus()); svrFactory.setServiceFactory(bean); String address = "local://localhost:9000/test"; svrFactory.setAddress(address); ServerImpl server = (ServerImpl)svrFactory.create(); Endpoint endpoint = server.getEndpoint(); Binding binding = endpoint.getBinding(); assertTrue(binding instanceof SoapBinding); SoapBindingInfo sb = (SoapBindingInfo)endpoint.getEndpointInfo().getBinding(); assertEquals("document", sb.getStyle()); assertFalse(bean.isWrapped()); assertEquals(1, sb.getOperations().size()); Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/sayHi.xml"); addNamespace("j", "http://service.jaxws.cxf.apache.org/"); assertValid("/s:Envelope/s:Body/j:sayHi", res); }
Example 6
Source File: AbstractRMInterceptor.java From cxf with Apache License 2.0 | 5 votes |
public void handleMessage(Message msg) throws Fault { try { handle(msg); } catch (SequenceFault sf) { // log the fault as it may not be reported back to the client Endpoint e = msg.getExchange().getEndpoint(); Binding b = null; if (null != e) { b = e.getBinding(); } if (null != b) { RMManager m = getManager(); LOG.fine("Manager: " + m); BindingFaultFactory bff = m.getBindingFaultFactory(b); Fault f = bff.createFault(sf, msg); // log with warning instead sever, as this may happen for some delayed messages LogUtils.log(LOG, Level.WARNING, "SEQ_FAULT_MSG", bff.toString(f)); throw f; } throw new Fault(sf); } catch (RMException ex) { throw new Fault(ex); } }
Example 7
Source File: SoapJMSInInterceptor.java From cxf with Apache License 2.0 | 5 votes |
private Fault createFault(SoapMessage message, JMSFault jmsFault) { Fault f = null; Endpoint e = message.getExchange().getEndpoint(); Binding b = null; if (null != e) { b = e.getBinding(); } if (null != b) { SoapFaultFactory sff = new SoapFaultFactory(b); f = sff.createFault(jmsFault); } return f; }
Example 8
Source File: EjbEndpoint.java From tomee with Apache License 2.0 | 5 votes |
protected void init() { // configure handlers try { initHandlers(); } catch (Exception e) { throw new WebServiceException("Error configuring handlers", e); } // Set service to invoke the target ejb service.setInvoker(new EjbMethodInvoker(this.bus, beanContext)); // Remove interceptors that perform handler processing since // handler processing must happen within the EJB container. Endpoint endpoint = getEndpoint(); removeHandlerInterceptors(bus.getInInterceptors()); removeHandlerInterceptors(endpoint.getInInterceptors()); removeHandlerInterceptors(endpoint.getBinding().getInInterceptors()); removeHandlerInterceptors(endpoint.getService().getInInterceptors()); // Install SAAJ interceptor if (endpoint.getBinding() instanceof SoapBinding && !this.implInfo.isWebServiceProvider()) { endpoint.getService().getInInterceptors().add(new SAAJInInterceptor()); } // Install WSS4J interceptor ConfigureCxfSecurity.configure(endpoint, port); }
Example 9
Source File: Servant.java From cxf with Apache License 2.0 | 4 votes |
public Object invoke(Exchange exchange, Object o) { LOG.fine("Invoking on RM Endpoint"); final ProtocolVariation protocol = RMContextUtils.getProtocolVariation(exchange.getInMessage()); OperationInfo oi = exchange.getBindingOperationInfo().getOperationInfo(); if (null == oi) { LOG.fine("No operation info."); return null; } if (RM10Constants.INSTANCE.getCreateSequenceOperationName().equals(oi.getName()) || RM11Constants.INSTANCE.getCreateSequenceOperationName().equals(oi.getName()) || RM10Constants.INSTANCE.getCreateSequenceOnewayOperationName().equals(oi.getName()) || RM11Constants.INSTANCE.getCreateSequenceOnewayOperationName().equals(oi.getName())) { try { return Collections.singletonList(createSequence(exchange.getInMessage())); } catch (RuntimeException ex) { LOG.log(Level.WARNING, "Sequence creation rejected", ex); SequenceFault sf = new SequenceFaultFactory(protocol.getConstants()).createCreateSequenceRefusedFault(); Endpoint e = exchange.getEndpoint(); Binding b = null == e ? null : e.getBinding(); if (null != b) { RMManager m = reliableEndpoint.getManager(); LOG.fine("Manager: " + m); BindingFaultFactory bff = m.getBindingFaultFactory(b); Fault f = bff.createFault(sf, exchange.getInMessage()); // log with warning instead sever, as this may happen for some delayed messages LogUtils.log(LOG, Level.WARNING, "SEQ_FAULT_MSG", bff.toString(f)); throw f; } throw new Fault(sf); } } else if (RM10Constants.INSTANCE.getCreateSequenceResponseOnewayOperationName().equals(oi.getName()) || RM11Constants.INSTANCE.getCreateSequenceResponseOnewayOperationName().equals(oi.getName())) { EncoderDecoder codec = protocol.getCodec(); CreateSequenceResponseType createResponse = codec.convertReceivedCreateSequenceResponse(getParameter(exchange.getInMessage())); createSequenceResponse(createResponse, protocol); } else if (RM10Constants.INSTANCE.getTerminateSequenceOperationName().equals(oi.getName()) || RM11Constants.INSTANCE.getTerminateSequenceOperationName().equals(oi.getName())) { Object tsr = terminateSequence(exchange.getInMessage()); if (tsr != null) { return Collections.singletonList(tsr); } } else if (RM11Constants.INSTANCE.getCloseSequenceOperationName().equals(oi.getName())) { return Collections.singletonList(closeSequence(exchange.getInMessage())); } return null; }
Example 10
Source File: SoapBindingFactory.java From cxf with Apache License 2.0 | 4 votes |
@Override public synchronized void addListener(Destination d, Endpoint e) { synchronized (d) { MessageObserver mo = d.getMessageObserver(); if (d.getAddress() != null && d.getAddress().getAddress() != null && d.getAddress().getAddress().getValue() != null && d.getAddress().getAddress().getValue().startsWith("soap.udp")) { //soap.udp REQUIRES usage of WS-Addressing... we need to turn this on setupUDP(e, e.getEndpointInfo()); } if (mo == null) { super.addListener(d, e); return; } if (mo instanceof ChainInitiationObserver) { ChainInitiationObserver cio = (ChainInitiationObserver) mo; Binding b = e.getBinding(); Binding b2 = cio.getEndpoint().getBinding(); if (b == b2) { //re-registering the same endpoint? return; } Object o = cio.getEndpoint().get("allow-multiplex-endpoint"); if (o instanceof String) { o = Boolean.parseBoolean((String)o); } else if (o == null) { o = Boolean.FALSE; } if (b instanceof org.apache.cxf.binding.soap.SoapBinding && b2 instanceof org.apache.cxf.binding.soap.SoapBinding && ((org.apache.cxf.binding.soap.SoapBinding)b).getSoapVersion() .equals(((org.apache.cxf.binding.soap.SoapBinding)b2).getSoapVersion()) && Boolean.FALSE.equals(o)) { throw new RuntimeException("Soap " + ((org.apache.cxf.binding.soap.SoapBinding)b) .getSoapVersion().getVersion() + " endpoint already registered on address " + e.getEndpointInfo().getAddress()); } MultipleEndpointObserver newMO = new MultipleEndpointObserver(getBus()) { @Override protected Message createMessage(Message message) { return new SoapMessage(message); } }; newMO.getBindingInterceptors().add(new AttachmentInInterceptor()); newMO.getBindingInterceptors().add(new StaxInInterceptor()); // This will not work if one of the endpoints disables message // processing. But, if you've disabled message processing, you // probably aren't going to use this feature. newMO.getBindingInterceptors().add(new ReadHeadersInterceptor(getBus(), (SoapVersion)null)); newMO.getBindingInterceptors().add(new StartBodyInterceptor()); newMO.getBindingInterceptors().add(new CheckFaultInterceptor()); // Add in a default selection interceptor newMO.getRoutingInterceptors().add(new EndpointSelectionInterceptor()); newMO.getEndpoints().add(cio.getEndpoint()); mo = newMO; } if (mo instanceof MultipleEndpointObserver) { MultipleEndpointObserver meo = (MultipleEndpointObserver) mo; meo.getEndpoints().add(e); } d.setMessageObserver(mo); } }