org.apache.cxf.binding.Binding Java Examples
The following examples show how to use
org.apache.cxf.binding.Binding.
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: ProtobufClient.java From fuchsia with Apache License 2.0 | 6 votes |
protected void setExchangeProperties(Exchange exchange, Endpoint ep) { if (ep != null) { exchange.put(Endpoint.class, ep); exchange.put(Service.class, ep.getService()); if (ep.getEndpointInfo().getService() != null) { exchange.put(ServiceInfo.class, ep.getEndpointInfo() .getService()); exchange.put(InterfaceInfo.class, ep.getEndpointInfo() .getService().getInterface()); } exchange.put(Binding.class, ep.getBinding()); exchange.put(BindingInfo.class, ep.getEndpointInfo().getBinding()); } exchange.put(MessageObserver.class, this); exchange.put(Bus.class, getBus()); }
Example #2
Source File: ColocMessageObserver.java From cxf with Apache License 2.0 | 6 votes |
protected void setExchangeProperties(Exchange exchange, Message m) { exchange.put(Bus.class, bus); exchange.put(Endpoint.class, endpoint); exchange.put(Service.class, endpoint.getService()); exchange.put(Binding.class, endpoint.getBinding()); //Setup the BindingOperationInfo QName opName = (QName) m.get(Message.WSDL_OPERATION); BindingInfo bi = endpoint.getEndpointInfo().getBinding(); BindingOperationInfo boi = bi.getOperation(opName); if (boi != null && boi.isUnwrapped()) { boi = boi.getWrappedOperation(); } exchange.put(BindingOperationInfo.class, boi); }
Example #3
Source File: XMLBindingFactory.java From cxf with Apache License 2.0 | 6 votes |
public Binding createBinding(BindingInfo binding) { XMLBinding xb = new XMLBinding(binding); xb.getInInterceptors().add(new AttachmentInInterceptor()); xb.getInInterceptors().add(new StaxInInterceptor()); xb.getInInterceptors().add(new DocLiteralInInterceptor()); xb.getInInterceptors().add(new XMLMessageInInterceptor()); xb.getOutInterceptors().add(new AttachmentOutInterceptor()); xb.getOutInterceptors().add(new StaxOutInterceptor()); xb.getOutInterceptors().add(new WrappedOutInterceptor()); xb.getOutInterceptors().add(new XMLMessageOutInterceptor()); xb.getInFaultInterceptors().add(new XMLFaultInInterceptor()); xb.getOutFaultInterceptors().add(new StaxOutInterceptor()); xb.getOutFaultInterceptors().add(new XMLFaultOutInterceptor()); return xb; }
Example #4
Source File: SoapBindingFactory.java From cxf with Apache License 2.0 | 6 votes |
public BindingInfo createBindingInfo(ServiceInfo service, javax.wsdl.Binding binding, String ns) { SoapBindingInfo bi = new SoapBindingInfo(service, ns); // Copy all the extensors initializeBindingInfo(service, binding, bi); SoapBinding wSoapBinding = SOAPBindingUtil.getSoapBinding(bi.getExtensors(ExtensibilityElement.class)); bi.setTransportURI(wSoapBinding.getTransportURI()); bi.setStyle(wSoapBinding.getStyle()); for (BindingOperationInfo boi : bi.getOperations()) { initializeBindingOperation(bi, boi); } return bi; }
Example #5
Source File: AbstractEndpointSelectionInterceptor.java From cxf with Apache License 2.0 | 6 votes |
public void handleMessage(Message message) { Exchange ex = message.getExchange(); Set<Endpoint> endpoints = CastUtils.cast((Set<?>)ex.get(MultipleEndpointObserver.ENDPOINTS)); Endpoint ep = selectEndpoint(message, endpoints); if (ep == null) { return; } ex.put(Endpoint.class, ep); ex.put(Binding.class, ep.getBinding()); ex.put(Service.class, ep.getService()); InterceptorChain chain = message.getInterceptorChain(); chain.add(ep.getInInterceptors()); chain.add(ep.getBinding().getInInterceptors()); chain.add(ep.getService().getInInterceptors()); chain.setFaultObserver(ep.getOutFaultObserver()); }
Example #6
Source File: ExchangeImpl.java From cxf with Apache License 2.0 | 6 votes |
public <T> T get(Class<T> key) { T t = key.cast(get(key.getName())); if (t == null) { if (key == Bus.class) { t = key.cast(bus); } else if (key == OperationInfo.class && bindingOp != null) { t = key.cast(bindingOp.getOperationInfo()); } else if (key == BindingOperationInfo.class) { t = key.cast(bindingOp); } else if (key == Endpoint.class) { t = key.cast(endpoint); } else if (key == Service.class) { t = key.cast(service); } else if (key == Binding.class) { t = key.cast(binding); } else if (key == BindingInfo.class && binding != null) { t = key.cast(binding.getBindingInfo()); } else if (key == InterfaceInfo.class && endpoint != null) { t = key.cast(endpoint.getEndpointInfo().getService().getInterface()); } else if (key == ServiceInfo.class && endpoint != null) { t = key.cast(endpoint.getEndpointInfo().getService()); } } return t; }
Example #7
Source File: ExchangeImpl.java From cxf with Apache License 2.0 | 6 votes |
public <T> void put(Class<T> key, T value) { if (value == null) { super.remove((Object)key); } else if (key == Bus.class) { resetContextCaches(); bus = (Bus)value; } else if (key == Endpoint.class) { resetContextCaches(); endpoint = (Endpoint)value; } else if (key == Service.class) { resetContextCaches(); service = (Service)value; } else if (key == BindingOperationInfo.class) { bindingOp = (BindingOperationInfo)value; } else if (key == Binding.class) { binding = (Binding)value; } else { super.put(key.getName(), value); } }
Example #8
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 #9
Source File: SOAPLoggingTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testSoap() { DefaultLogEventMapper mapper = new DefaultLogEventMapper(); Message message = new MessageImpl(); ExchangeImpl exchange = new ExchangeImpl(); ServiceInfo service = new ServiceInfo(); BindingInfo info = new BindingInfo(service, "bindingId"); SoapBinding value = new SoapBinding(info); exchange.put(Binding.class, value); OperationInfo opInfo = new OperationInfo(); opInfo.setName(new QName("http://my", "Operation")); BindingOperationInfo boi = new BindingOperationInfo(info, opInfo); exchange.put(BindingOperationInfo.class, boi); message.setExchange(exchange); LogEvent event = mapper.map(message); Assert.assertEquals("{http://my}Operation", event.getOperationName()); }
Example #10
Source File: DocLiteralInInterceptorTest.java From cxf with Apache License 2.0 | 6 votes |
private void setUpUsingDocLit() throws Exception { String ns = "http://apache.org/hello_world_doc_lit_bare"; WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass() .getResource("/wsdl/jaxb/doc_lit_bare.wsdl").toString(), new QName(ns, "SOAPService")); service = factory.create(); endpointInfo = service.getEndpointInfo(new QName(ns, "SoapPort")); endpoint = new EndpointImpl(bus, service, endpointInfo); JAXBDataBinding db = new JAXBDataBinding(); db.setContext(JAXBContext.newInstance(new Class[] {TradePriceData.class})); service.setDataBinding(db); operation = endpointInfo.getBinding().getOperation(new QName(ns, "SayHi")); operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(TradePriceData.class); operation.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(TradePriceData.class); message = new MessageImpl(); Exchange exchange = new ExchangeImpl(); message.setExchange(exchange); exchange.put(Service.class, service); exchange.put(Endpoint.class, endpoint); exchange.put(Binding.class, endpoint.getBinding()); }
Example #11
Source File: DocLiteralInInterceptorTest.java From cxf with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { bus = BusFactory.newInstance().createBus(); BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class); IMocksControl control = createNiceControl(); BindingFactory bf = control.createMock(BindingFactory.class); Binding binding = control.createMock(Binding.class); expect(bf.createBinding(null)).andStubReturn(binding); expect(binding.getInFaultInterceptors()) .andStubReturn(new ArrayList<Interceptor<? extends Message>>()); expect(binding.getOutFaultInterceptors()) .andStubReturn(new ArrayList<Interceptor<? extends Message>>()); bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bf); }
Example #12
Source File: BareInInterceptorTest.java From cxf with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { bus = BusFactory.newInstance().createBus(); BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class); IMocksControl control = createNiceControl(); BindingFactory bf = control.createMock(BindingFactory.class); Binding binding = control.createMock(Binding.class); expect(bf.createBinding(null)).andStubReturn(binding); expect(binding.getInFaultInterceptors()) .andStubReturn(new ArrayList<Interceptor<? extends Message>>()); expect(binding.getOutFaultInterceptors()) .andStubReturn(new ArrayList<Interceptor<? extends Message>>()); bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bf); }
Example #13
Source File: DocLiteralInInterceptorTest.java From cxf with Apache License 2.0 | 6 votes |
private void setUpUsingHelloWorld() throws Exception { String ns = "http://apache.org/hello_world_soap_http"; WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass() .getResource("/wsdl/jaxb/hello_world.wsdl").toString(), new QName(ns, "SOAPService")); service = factory.create(); endpointInfo = service.getEndpointInfo(new QName(ns, "SoapPort")); endpoint = new EndpointImpl(bus, service, endpointInfo); JAXBDataBinding db = new JAXBDataBinding(); db.setContext(JAXBContext.newInstance(new Class[] {GreetMe.class, GreetMeResponse.class})); service.setDataBinding(db); operation = endpointInfo.getBinding().getOperation(new QName(ns, "greetMe")); operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(GreetMe.class); operation.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(GreetMeResponse.class); message = new MessageImpl(); Exchange exchange = new ExchangeImpl(); message.setExchange(exchange); exchange.put(Service.class, service); exchange.put(Endpoint.class, endpoint); exchange.put(Binding.class, endpoint.getBinding()); }
Example #14
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 #15
Source File: ColocMessageObserverTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testObserverOnMessage() throws Exception { msg.setExchange(ex); Binding binding = control.createMock(Binding.class); EasyMock.expect(ep.getBinding()).andReturn(binding); Message inMsg = new MessageImpl(); EasyMock.expect(binding.createMessage()).andReturn(inMsg); EasyMock.expect(ep.getService()).andReturn(srv).anyTimes(); EasyMock.expect( bus.getExtension(PhaseManager.class)).andReturn( new PhaseManagerImpl()).times(2); EasyMock.expect(bus.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()); EasyMock.expect(ep.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()); EasyMock.expect(srv.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()); EasyMock.expect(bus.getExtension(ClassLoader.class)).andReturn(this.getClass().getClassLoader()); control.replay(); observer = new TestColocMessageObserver(ep, bus); observer.onMessage(msg); control.verify(); Exchange inEx = inMsg.getExchange(); assertNotNull("Should Have a valid Exchange", inEx); assertFalse("Message.REQUESTOR_ROLE should be false", (Boolean)inMsg.get(Message.REQUESTOR_ROLE)); assertTrue("Message.INBOUND_MESSAGE should be true", (Boolean)inMsg.get(Message.INBOUND_MESSAGE)); assertNotNull("Chain should be set", inMsg.getInterceptorChain()); Exchange ex1 = msg.getExchange(); assertNotNull("Exchange should be set", ex1); }
Example #16
Source File: ColocMessageObserverTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testSetExchangeProperties() throws Exception { QName opName = new QName("A", "B"); msg.put(Message.WSDL_OPERATION, opName); EasyMock.expect(ep.getService()).andReturn(srv); Binding binding = control.createMock(Binding.class); EasyMock.expect(ep.getBinding()).andReturn(binding); EndpointInfo ei = control.createMock(EndpointInfo.class); EasyMock.expect(ep.getEndpointInfo()).andReturn(ei); BindingInfo bi = control.createMock(BindingInfo.class); EasyMock.expect(ei.getBinding()).andReturn(bi); BindingOperationInfo boi = control.createMock(BindingOperationInfo.class); EasyMock.expect(bi.getOperation(opName)).andReturn(boi); EasyMock.expect(bus.getExtension(ClassLoader.class)).andReturn(this.getClass().getClassLoader()); control.replay(); observer = new ColocMessageObserver(ep, bus); observer.setExchangeProperties(ex, msg); control.verify(); assertNotNull("Bus should be set", ex.getBus()); assertNotNull("Endpoint should be set", ex.getEndpoint()); assertNotNull("Binding should be set", ex.getBinding()); assertNotNull("Service should be set", ex.getService()); assertNotNull("BindingOperationInfo should be set", ex.getBindingOperationInfo()); }
Example #17
Source File: ColocOutInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testInvokeInboundChain() { //Reset Exchange on msg msg.setExchange(null); Bus bus = setupBus(); colocOut.setBus(bus); PhaseManager pm = new PhaseManagerImpl(); EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(pm).times(2); Endpoint ep = control.createMock(Endpoint.class); Binding bd = control.createMock(Binding.class); Service srv = control.createMock(Service.class); ex.setInMessage(msg); ex.put(Bus.class, bus); ex.put(Endpoint.class, ep); ex.put(Service.class, srv); EasyMock.expect(ep.getBinding()).andReturn(bd); EasyMock.expect(bd.createMessage()).andReturn(new MessageImpl()); EasyMock.expect(ep.getInInterceptors()) .andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce(); EasyMock.expect(ep.getService()).andReturn(srv).atLeastOnce(); EasyMock.expect(srv.getInInterceptors()) .andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce(); EasyMock.expect(bus.getInInterceptors()) .andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce(); control.replay(); colocOut.invokeInboundChain(ex, ep); Message inMsg = ex.getInMessage(); assertNotSame(msg, inMsg); assertTrue("Requestor role should be set to true.", (Boolean)inMsg.get(Message.REQUESTOR_ROLE)); assertTrue("Inbound Message should be set to true.", (Boolean)inMsg.get(Message.INBOUND_MESSAGE)); assertNotNull("Inbound Message should have interceptor chain set.", inMsg.getInterceptorChain()); assertTrue("Client Invoke state should be FINISHED", (Boolean)ex.get(ClientImpl.FINISHED)); control.verify(); }
Example #18
Source File: OutgoingChainInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testInterceptor() throws Exception { OutgoingChainInterceptor intc = new OutgoingChainInterceptor(); MessageImpl m = new MessageImpl(); Exchange exchange = new ExchangeImpl(); m.setExchange(exchange); exchange.put(Bus.class, bus); exchange.put(Endpoint.class, endpoint); exchange.put(Binding.class, binding); exchange.put(BindingOperationInfo.class, bopInfo); exchange.setOutMessage(m); intc.handleMessage(m); }
Example #19
Source File: CorbaBindingFactory.java From cxf with Apache License 2.0 | 5 votes |
public Binding createBinding(BindingInfo bindingInfo) { CorbaBinding binding = new CorbaBinding(); binding.getInFaultInterceptors().add(new CorbaStreamFaultInInterceptor()); binding.getOutFaultInterceptors().add(new CorbaStreamFaultOutInterceptor()); binding.getOutInterceptors().add(new BareOutInterceptor()); binding.getOutInterceptors().add(new CorbaStreamOutInterceptor()); binding.getInInterceptors().add(new BareInInterceptor()); binding.getInInterceptors().add(new CorbaStreamInInterceptor()); binding.setBindingInfo(bindingInfo); return binding; }
Example #20
Source File: XMLBindingFactoryTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testContainsInAttachmentInterceptor() { XMLBindingFactory xbf = new XMLBindingFactory(); Binding b = xbf.createBinding(new BindingInfo(null, null)); boolean found = false; for (Interceptor<? extends Message> interseptor : b.getInInterceptors()) { if (interseptor instanceof AttachmentInInterceptor) { found = true; } } assertTrue("No in attachment interceptor found", found); }
Example #21
Source File: OutgoingChainInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { control = EasyMock.createNiceControl(); phases = new ArrayList<>(); phases.add(new Phase(Phase.SEND, 1000)); empty = new ArrayList<>(); bus = control.createMock(Bus.class); PhaseManager pm = new PhaseManagerImpl(); EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(pm).anyTimes(); service = control.createMock(Service.class); endpoint = control.createMock(Endpoint.class); binding = control.createMock(Binding.class); EasyMock.expect(endpoint.getBinding()).andStubReturn(binding); MessageImpl m = new MessageImpl(); EasyMock.expect(binding.createMessage()).andStubReturn(m); EasyMock.expect(endpoint.getService()).andReturn(service).anyTimes(); EasyMock.expect(endpoint.getOutInterceptors()).andReturn(empty); EasyMock.expect(service.getOutInterceptors()).andReturn(empty); EasyMock.expect(bus.getOutInterceptors()).andReturn(empty); bopInfo = control.createMock(BindingOperationInfo.class); opInfo = control.createMock(OperationInfo.class); mInfo = control.createMock(MessageInfo.class); bmInfo = control.createMock(BindingMessageInfo.class); EasyMock.expect(bopInfo.getOperationInfo()).andReturn(opInfo).times(3); EasyMock.expect(opInfo.getOutput()).andReturn(mInfo); EasyMock.expect(opInfo.isOneWay()).andReturn(false); EasyMock.expect(bopInfo.getOutput()).andReturn(bmInfo); control.replay(); }
Example #22
Source File: AbstractRMInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testHandleMessageSequenceFault() { RMInterceptor interceptor = new RMInterceptor(); Message message = control.createMock(Message.class); SequenceFault sf = control.createMock(SequenceFault.class); interceptor.setSequenceFault(sf); Exchange ex = control.createMock(Exchange.class); EasyMock.expect(message.getExchange()).andReturn(ex).anyTimes(); Endpoint e = control.createMock(Endpoint.class); EasyMock.expect(ex.getEndpoint()).andReturn(e); Binding b = control.createMock(Binding.class); EasyMock.expect(e.getBinding()).andReturn(b); RMManager mgr = control.createMock(RMManager.class); interceptor.setManager(mgr); BindingFaultFactory bff = control.createMock(BindingFaultFactory.class); EasyMock.expect(mgr.getBindingFaultFactory(b)).andReturn(bff); Fault fault = control.createMock(Fault.class); EasyMock.expect(bff.createFault(sf, message)).andReturn(fault); EasyMock.expect(bff.toString(fault)).andReturn("f"); control.replay(); try { interceptor.handleMessage(message); fail("Expected Fault not thrown."); } catch (Fault f) { assertSame(f, fault); } }
Example #23
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 #24
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 #25
Source File: BareInInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
private void setUpUsingHelloWorld() throws Exception { String ns = "http://apache.org/hello_world_soap_http"; WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass() .getResource("/wsdl/jaxb/hello_world.wsdl").toString(), new QName(ns, "SOAPService")); service = factory.create(); endpointInfo = service.getServiceInfos().get(0).getEndpoint(new QName(ns, "SoapPort")); endpoint = new EndpointImpl(bus, service, endpointInfo); JAXBDataBinding db = new JAXBDataBinding(); db.setContext(JAXBContext.newInstance(new Class[] { GreetMe.class, GreetMeResponse.class })); service.setDataBinding(db); operation = endpointInfo.getBinding().getOperation(new QName(ns, "greetMe")); operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(GreetMe.class); operation.getOperationInfo().getOutput() .getMessagePartByIndex(0).setTypeClass(GreetMeResponse.class); message = new MessageImpl(); Exchange exchange = new ExchangeImpl(); message.setExchange(exchange); exchange.put(Service.class, service); exchange.put(Endpoint.class, endpoint); exchange.put(Binding.class, endpoint.getBinding()); }
Example #26
Source File: BareInInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
private void setUpUsingDocLit() throws Exception { String ns = "http://apache.org/hello_world_doc_lit_bare"; WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass() .getResource("/wsdl/jaxb/doc_lit_bare.wsdl").toString(), new QName(ns, "SOAPService")); service = factory.create(); endpointInfo = service.getServiceInfos().get(0).getEndpoint(new QName(ns, "SoapPort")); endpoint = new EndpointImpl(bus, service, endpointInfo); JAXBDataBinding db = new JAXBDataBinding(); db.setContext(JAXBContext.newInstance(new Class[] { TradePriceData.class })); service.setDataBinding(db); operation = endpointInfo.getBinding().getOperation(new QName(ns, "SayHi")); operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(TradePriceData.class); operation.getOperationInfo().getOutput() .getMessagePartByIndex(0).setTypeClass(TradePriceData.class); message = new MessageImpl(); Exchange exchange = new ExchangeImpl(); message.setExchange(exchange); exchange.put(Service.class, service); exchange.put(Endpoint.class, endpoint); exchange.put(Binding.class, endpoint.getBinding()); }
Example #27
Source File: RMCaptureOutInterceptor.java From cxf with Apache License 2.0 | 5 votes |
private void setTerminateSequence(Message msg, Identifier identifier, ProtocolVariation protocol) throws RMException { TerminateSequenceType ts = new TerminateSequenceType(); ts.setIdentifier(identifier); MessageContentsList contents = new MessageContentsList(new Object[]{protocol.getCodec().convertToSend(ts)}); msg.setContent(List.class, contents); // create a new exchange for this output-only exchange Exchange newex = new ExchangeImpl(); Exchange oldex = msg.getExchange(); newex.put(Bus.class, oldex.getBus()); newex.put(Endpoint.class, oldex.getEndpoint()); newex.put(Service.class, oldex.getEndpoint().getService()); newex.put(Binding.class, oldex.getEndpoint().getBinding()); newex.setConduit(oldex.getConduit(msg)); newex.setDestination(oldex.getDestination()); //Setup the BindingOperationInfo RMEndpoint rmep = getManager().getReliableEndpoint(msg); OperationInfo oi = rmep.getEndpoint(protocol).getEndpointInfo().getService().getInterface() .getOperation(protocol.getConstants().getTerminateSequenceAnonymousOperationName()); BindingInfo bi = rmep.getBindingInfo(protocol); BindingOperationInfo boi = bi.getOperation(oi); newex.put(BindingInfo.class, bi); newex.put(BindingOperationInfo.class, boi); msg.setExchange(newex); newex.setOutMessage(msg); }
Example #28
Source File: OutgoingChainInterceptor.java From cxf with Apache License 2.0 | 5 votes |
public static InterceptorChain getOutInterceptorChain(Exchange ex) { Bus bus = ex.getBus(); Binding binding = ex.getBinding(); PhaseManager pm = bus.getExtension(PhaseManager.class); PhaseInterceptorChain chain = new PhaseInterceptorChain(pm.getOutPhases()); Endpoint ep = ex.getEndpoint(); List<Interceptor<? extends Message>> il = ep.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by endpoint: " + il); } chain.add(il); il = ep.getService().getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by service: " + il); } chain.add(il); il = bus.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by bus: " + il); } chain.add(il); if (binding != null) { il = binding.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by binding: " + il); } chain.add(il); } modifyChain(chain, ex); chain.setFaultObserver(ep.getOutFaultObserver()); return chain; }
Example #29
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 #30
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); }