org.apache.cxf.service.Service Java Examples
The following examples show how to use
org.apache.cxf.service.Service.
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: CodeFirstTest.java From cxf with Apache License 2.0 | 6 votes |
private Definition createService(boolean wrapped) throws Exception { ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean(); Bus bus = getBus(); bean.setBus(bus); bean.setServiceClass(Hello.class); bean.setWrapped(wrapped); Service service = bean.create(); InterfaceInfo i = service.getServiceInfos().get(0).getInterface(); assertEquals(5, i.getOperations().size()); ServerFactoryBean svrFactory = new ServerFactoryBean(); svrFactory.setBus(bus); svrFactory.setServiceFactory(bean); svrFactory.setAddress(address); svrFactory.create(); Collection<BindingInfo> bindings = service.getServiceInfos().get(0).getBindings(); assertEquals(1, bindings.size()); ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, service.getServiceInfos().get(0)); return wsdlBuilder.build(); }
Example #2
Source File: EndpointImpl.java From cxf with Apache License 2.0 | 6 votes |
public EndpointImpl(Bus bus, Service s, EndpointInfo ei) throws EndpointException { if (ei == null) { throw new NullPointerException("EndpointInfo can not be null!"); } if (bus == null) { this.bus = BusFactory.getThreadDefaultBus(); } else { this.bus = bus; } service = s; endpointInfo = ei; createBinding(endpointInfo.getBinding()); inFaultObserver = new InFaultChainInitiatorObserver(bus); outFaultObserver = new OutFaultChainInitiatorObserver(bus); getInFaultInterceptors().add(new ClientFaultConverter()); getOutInterceptors().add(new MessageSenderInterceptor()); getOutFaultInterceptors().add(new MessageSenderInterceptor()); }
Example #3
Source File: AbstractJAXRSFactoryBean.java From cxf with Apache License 2.0 | 6 votes |
protected void setDataBindingProvider(ProviderFactory factory, Service s) { List<ClassResourceInfo> cris = serviceFactory.getRealClassResourceInfo(); if (getDataBinding() == null && !cris.isEmpty()) { org.apache.cxf.annotations.DataBinding ann = cris.get(0).getServiceClass().getAnnotation(org.apache.cxf.annotations.DataBinding.class); if (ann != null) { try { setDataBinding(ann.value().newInstance()); } catch (Exception ex) { LOG.warning("DataBinding " + ann.value() + " can not be loaded"); } } } DataBinding db = getDataBinding(); if (db == null) { return; } if (s instanceof JAXRSServiceImpl) { ((JAXRSServiceImpl)s).setCreateServiceModel(true); } db.initialize(s); factory.setUserProviders(Collections.singletonList(new DataBindingProvider<Object>(db))); }
Example #4
Source File: WrapperClassOutInterceptor.java From cxf with Apache License 2.0 | 6 votes |
private synchronized WrapperHelper getWrapperHelper(Message message, MessageInfo messageInfo, MessageInfo wrappedMessageInfo, Class<?> wrapClass, MessagePartInfo messagePartInfo) { WrapperHelper helper = messagePartInfo.getProperty("WRAPPER_CLASS", WrapperHelper.class); if (helper == null) { Service service = ServiceModelUtil.getService(message.getExchange()); DataBinding dataBinding = service.getDataBinding(); if (dataBinding instanceof WrapperCapableDatabinding) { helper = createWrapperHelper((WrapperCapableDatabinding)dataBinding, messageInfo, wrappedMessageInfo, wrapClass); messagePartInfo.setProperty("WRAPPER_CLASS", helper); } } return helper; }
Example #5
Source File: StaxDataBinding.java From cxf with Apache License 2.0 | 6 votes |
public void initialize(Service service) { for (ServiceInfo serviceInfo : service.getServiceInfos()) { SchemaCollection schemaCollection = serviceInfo.getXmlSchemaCollection(); if (schemaCollection.getXmlSchemas().length > 1) { // Schemas are already populated. continue; } new ServiceModelVisitor(serviceInfo) { public void begin(MessagePartInfo part) { if (part.getTypeQName() != null || part.getElementQName() != null) { return; } part.setTypeQName(Constants.XSD_ANYTYPE); } } .walk(); } }
Example #6
Source File: JaxWsClientTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testThreadLocalRequestContextIsIsolated() throws InterruptedException { URL url = getClass().getResource("/wsdl/hello_world.wsdl"); javax.xml.ws.Service s = javax.xml.ws.Service.create(url, SERVICE_NAME); final Greeter handler = s.getPort(PORT_NAME, Greeter.class); final AtomicBoolean isPropertyAPresent = new AtomicBoolean(false); // Makes request context thread local ClientProxy.getClient(handler).setThreadLocalRequestContext(true); // PropertyA should be added to the request context of current thread only ClientProxy.getClient(handler).getRequestContext().put("PropertyA", "PropertyAVal"); Runnable checkRequestContext = new Runnable() { @Override public void run() { if (ClientProxy.getClient(handler).getRequestContext().containsKey("PropertyA")) { isPropertyAPresent.set(true); } } }; Thread thread = new Thread(checkRequestContext); thread.start(); thread.join(60000); assertFalse("If we have per thread isolation propertyA should be not present in the context of another thread.", isPropertyAPresent.get()); }
Example #7
Source File: AbstractOutDatabindingInterceptor.java From cxf with Apache License 2.0 | 6 votes |
protected boolean writeToOutputStream(Message m, BindingInfo info, Service s) { /** * Yes, all this code is EXTREMELY ugly. But it gives about a 60-70% performance * boost with the JAXB RI, so its worth it. */ if (s == null) { return false; } String enc = (String)m.get(Message.ENCODING); return "org.apache.cxf.binding.soap.model.SoapBindingInfo".equals(info.getClass().getName()) && "org.apache.cxf.jaxb.JAXBDataBinding".equals(s.getDataBinding().getClass().getName()) && !MessageUtils.isDOMPresent(m) && (enc == null || StandardCharsets.UTF_8.name().equals(enc)); }
Example #8
Source File: AegisDatabinding.java From cxf with Apache License 2.0 | 6 votes |
private void initializeOperation(Service s, TypeMapping serviceTM, OperationInfo opInfo, Set<AegisType> deps) { try { initializeMessage(s, serviceTM, opInfo.getInput(), IN_PARAM, deps); if (opInfo.hasOutput()) { initializeMessage(s, serviceTM, opInfo.getOutput(), OUT_PARAM, deps); } for (FaultInfo info : opInfo.getFaults()) { initializeMessage(s, serviceTM, info, FAULT_PARAM, deps); } } catch (DatabindingException e) { e.prepend("Error initializing parameters for operation " + opInfo.getName()); throw e; } }
Example #9
Source File: AuthorizationHandler.java From geofence with GNU General Public License v2.0 | 6 votes |
protected Method getTargetMethod(Message m) { BindingOperationInfo bop = m.getExchange().get(BindingOperationInfo.class); if (bop != null) { MethodDispatcher md = (MethodDispatcher) m.getExchange().get(Service.class).get(MethodDispatcher.class.getName()); return md.getMethod(bop); } Method method = (Method) m.get("org.apache.cxf.resource.method"); if (method != null) { return method; } throw new AccessDeniedException("Method is not available : Unauthorized"); }
Example #10
Source File: AbstractOutDatabindingInterceptor.java From cxf with Apache License 2.0 | 6 votes |
protected <T> DataWriter<T> getDataWriter(Message message, Service service, Class<T> output) { DataWriter<T> writer = service.getDataBinding().createWriter(output); Collection<Attachment> atts = message.getAttachments(); if (MessageUtils.getContextualBoolean(message, Message.MTOM_ENABLED, false) && atts == null) { atts = new ArrayList<>(); message.setAttachments(atts); } writer.setAttachments(atts); writer.setProperty(DataWriter.ENDPOINT, message.getExchange().getEndpoint()); writer.setProperty(Message.class.getName(), message); setDataWriterValidation(service, message, writer); return writer; }
Example #11
Source File: PhaseInterceptorChain.java From cxf with Apache License 2.0 | 6 votes |
private String getServiceInfo(Message message) { StringBuilder description = new StringBuilder(); if (message.getExchange() != null) { Exchange exchange = message.getExchange(); Service service = exchange.getService(); if (service != null) { description.append('\''); description.append(service.getName()); BindingOperationInfo boi = exchange.getBindingOperationInfo(); OperationInfo opInfo = boi != null ? boi.getOperationInfo() : null; if (opInfo != null) { description.append('#').append(opInfo.getName()); } description.append("\' "); } } return description.toString(); }
Example #12
Source File: ColocOutInterceptor.java From cxf with Apache License 2.0 | 6 votes |
protected Server isColocated(List<Server> servers, Endpoint endpoint, BindingOperationInfo boi) { if (servers != null) { Service senderService = endpoint.getService(); EndpointInfo senderEI = endpoint.getEndpointInfo(); for (Server s : servers) { Endpoint receiverEndpoint = s.getEndpoint(); Service receiverService = receiverEndpoint.getService(); EndpointInfo receiverEI = receiverEndpoint.getEndpointInfo(); if (receiverService.getName().equals(senderService.getName()) && receiverEI.getName().equals(senderEI.getName())) { //Check For Operation Match. BindingOperationInfo receiverOI = receiverEI.getBinding().getOperation(boi.getName()); if (receiverOI != null && isCompatibleOperationInfo(boi, receiverOI)) { return s; } } } } return null; }
Example #13
Source File: StaxRoundTripActionTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testTimestampConfig() throws Exception { // Create + configure service Service service = createService(); Map<String, Object> inConfig = new HashMap<>(); inConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.TIMESTAMP); WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); // Create + configure client Echo echo = createClientProxy(); Client client = ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map<String, Object> outConfig = new HashMap<>(); outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.TIMESTAMP); WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test", echo.echo("test")); }
Example #14
Source File: ServiceUtils.java From fuchsia with Apache License 2.0 | 5 votes |
public static Service createServiceModel() { ServiceInfo serviceInfo = new ServiceInfo(); // does not make sense for protobuf services serviceInfo.setName(new QName("", "protobuf_service_" + System.identityHashCode(serviceInfo))); InterfaceInfo interfaceInfo = new InterfaceInfo(serviceInfo, serviceInfo.getName()); serviceInfo.setInterface(interfaceInfo); Service service = new ServiceImpl(serviceInfo); return service; }
Example #15
Source File: DynamicClientFactory.java From cxf with Apache License 2.0 | 5 votes |
DynamicClientImpl(Bus bus, Service svc, QName port, EndpointImplFactory endpointImplFactory, ClassLoader l) { super(bus, svc, port, endpointImplFactory); cl = l; orig = Thread.currentThread().getContextClassLoader(); }
Example #16
Source File: CorbaConduitTest.java From cxf with Apache License 2.0 | 5 votes |
protected void setupServiceInfo(String ns, String wsdl, String serviceName, String portName) { URL wsdlUrl = getClass().getResource(wsdl); assertNotNull(wsdlUrl); WSDLServiceFactory f = new WSDLServiceFactory(bus, wsdlUrl.toString(), new QName(ns, serviceName)); Service service = f.create(); endpointInfo = service.getEndpointInfo(new QName(ns, portName)); }
Example #17
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 #18
Source File: CorbaStreamFaultInInterceptor.java From cxf with Apache License 2.0 | 5 votes |
protected DataReader<XMLStreamReader> getDataReader(CorbaMessage message) { Service serviceModel = ServiceModelUtil.getService(message.getExchange()); DataReader<XMLStreamReader> dataReader = serviceModel.getDataBinding().createReader(XMLStreamReader.class); if (dataReader == null) { throw new CorbaBindingException("Couldn't create data reader for incoming fault message"); } return dataReader; }
Example #19
Source File: SimpleAuthorizingInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { method = TestService.class.getMethod("echo", new Class[]{}); Exchange ex = setUpExchange(); Service service = EasyMock.createMock(Service.class); ex.put(Service.class, service); MethodDispatcher md = EasyMock.createMock(MethodDispatcher.class); EasyMock.expect(service.get(MethodDispatcher.class.getName())).andReturn(md); BindingOperationInfo boi = EasyMock.createMock(BindingOperationInfo.class); ex.put(BindingOperationInfo.class, boi); EasyMock.expect(md.getMethod(boi)).andReturn(method); EasyMock.replay(service, md); }
Example #20
Source File: StaxToDOMSignatureIdentifierTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testSignatureIssuerSerial() throws Exception { // Create + configure service Service service = createService(); Map<String, Object> inProperties = new HashMap<>(); inProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE); inProperties.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback()); inProperties.put(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties"); WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); // Create + configure client Echo echo = createClientProxy(); Client client = ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties = new WSSSecurityProperties(); List<WSSConstants.Action> actions = new ArrayList<>(); actions.add(XMLSecurityConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureKeyIdentifier( WSSecurityTokenConstants.KeyIdentifier_IssuerSerial ); properties.setSignatureUser("myalias"); Properties cryptoProperties = CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test", echo.echo("test")); }
Example #21
Source File: StaxToDOMRoundTripTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testSignature() throws Exception { // Create + configure service Service service = createService(); Map<String, Object> inProperties = new HashMap<>(); inProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE); inProperties.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback()); inProperties.put(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties"); WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); // Create + configure client Echo echo = createClientProxy(); Client client = ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties = new WSSSecurityProperties(); List<WSSConstants.Action> actions = new ArrayList<>(); actions.add(XMLSecurityConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureUser("myalias"); Properties cryptoProperties = CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test", echo.echo("test")); }
Example #22
Source File: StratosAuthorizingHandler.java From product-private-paas with Apache License 2.0 | 5 votes |
/** * Here we are getting the target invocation method. The method get set as a property in the * message by the {@link org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor} * * @param message incoming message * @return */ protected Method getTargetMethod(Message message) { BindingOperationInfo bop = message.getExchange().get(BindingOperationInfo.class); if (bop != null) { MethodDispatcher md = (MethodDispatcher) message.getExchange().get(Service.class) .get(MethodDispatcher.class.getName()); return md.getMethod(bop); } Method method = (Method) message.get("org.apache.cxf.resource.method"); if (method != null) { return method; } log.error("The requested resource is not found. Please check the resource path etc.."); throw new AccessDeniedException("Method is not available : Unauthorized"); }
Example #23
Source File: AbstractInDatabindingInterceptor.java From cxf with Apache License 2.0 | 5 votes |
protected <T> DataReader<T> getDataReader(Message message, Class<T> input) { Service service = ServiceModelUtil.getService(message.getExchange()); DataReader<T> dataReader = service.getDataBinding().createReader(input); if (dataReader == null) { throw new Fault(new org.apache.cxf.common.i18n.Message("NO_DATAREADER", BUNDLE, service.getName())); } dataReader.setAttachments(message.getAttachments()); dataReader.setProperty(DataReader.ENDPOINT, message.getExchange().getEndpoint()); dataReader.setProperty(Message.class.getName(), message); setDataReaderValidation(service, message, dataReader); return dataReader; }
Example #24
Source File: CorbaStreamFaultOutInterceptor.java From cxf with Apache License 2.0 | 5 votes |
protected DataWriter<XMLStreamWriter> getDataWriter(CorbaMessage message) { Service serviceModel = ServiceModelUtil.getService(message.getExchange()); DataWriter<XMLStreamWriter> dataWriter = serviceModel.getDataBinding().createWriter(XMLStreamWriter.class); if (dataWriter == null) { throw new CorbaBindingException("Couldn't create data writer for outgoing fault message"); } return dataWriter; }
Example #25
Source File: WadlGeneratorJsonTest.java From cxf with Apache License 2.0 | 5 votes |
private Message mockMessage(String baseAddress, String pathInfo, String query, ClassResourceInfo cri) throws Exception { Message m = new MessageImpl(); Exchange e = new ExchangeImpl(); e.put(Service.class, new JAXRSServiceImpl(Collections.singletonList(cri))); m.setExchange(e); control.reset(); ServletDestination d = control.createMock(ServletDestination.class); EndpointInfo epr = new EndpointInfo(); epr.setAddress(baseAddress); d.getEndpointInfo(); EasyMock.expectLastCall().andReturn(epr).anyTimes(); Endpoint endpoint = new EndpointImpl(null, null, epr); e.put(Endpoint.class, endpoint); e.setDestination(d); BindingInfo bi = control.createMock(BindingInfo.class); epr.setBinding(bi); bi.getProperties(); EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes(); m.put(Message.REQUEST_URI, pathInfo); m.put(Message.QUERY_STRING, query); m.put(Message.HTTP_REQUEST_METHOD, "GET"); control.replay(); return m; }
Example #26
Source File: StaxToDOMRoundTripTest.java From cxf with Apache License 2.0 | 5 votes |
private Service createService() { // Create the Service JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setServiceBean(new EchoImpl()); factory.setAddress("local://Echo"); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); Server server = factory.create(); Service service = server.getEndpoint().getService(); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); return service; }
Example #27
Source File: StaxToDOMSamlTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testSaml1Config() throws Exception { // Create + configure service Service service = createService(); Map<String, Object> inProperties = new HashMap<>(); inProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SAML_TOKEN_UNSIGNED); final Map<QName, Object> customMap = new HashMap<>(); CustomSamlValidator validator = new CustomSamlValidator(); customMap.put(WSConstants.SAML_TOKEN, validator); customMap.put(WSConstants.SAML2_TOKEN, validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP, customMap); inProperties.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION, "false"); WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); service.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION, "false"); // Create + configure client Echo echo = createClientProxy(); Client client = ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map<String, Object> outConfig = new HashMap<>(); outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.SAML_TOKEN_UNSIGNED); outConfig.put(ConfigurationConstants.SAML_CALLBACK_REF, new SAML1CallbackHandler()); WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test", echo.echo("test")); }
Example #28
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 #29
Source File: AbstractOutDatabindingInterceptor.java From cxf with Apache License 2.0 | 5 votes |
/** * Based on the Schema Validation configuration, will initialise the DataWriter with or without the schema set. */ private void setDataWriterValidation(Service service, Message message, DataWriter<?> writer) { if (shouldValidate(message)) { Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0), message.getExchange().getBus()); writer.setSchema(schema); } }
Example #30
Source File: ColocOutInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
private void verifyIsColocatedWithDifferentOperation() { //Funtion Param Server s1 = control.createMock(Server.class); List<Server> list = new ArrayList<>(); list.add(s1); Endpoint sep = control.createMock(Endpoint.class); BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class); //Local var Service ses = control.createMock(Service.class); ServiceInfo ssi = control.createMock(ServiceInfo.class); EndpointInfo sei = control.createMock(EndpointInfo.class); TestBindingInfo rbi = new TestBindingInfo(ssi, "testBinding"); Endpoint rep = control.createMock(Endpoint.class); Service res = control.createMock(Service.class); EndpointInfo rei = control.createMock(EndpointInfo.class); EasyMock.expect(sep.getService()).andReturn(ses); EasyMock.expect(sep.getEndpointInfo()).andReturn(sei); EasyMock.expect(s1.getEndpoint()).andReturn(rep); EasyMock.expect(rep.getService()).andReturn(res); EasyMock.expect(rep.getEndpointInfo()).andReturn(rei); EasyMock.expect(ses.getName()).andReturn(new QName("A", "B")); EasyMock.expect(res.getName()).andReturn(new QName("A", "B")); EasyMock.expect(rei.getName()).andReturn(new QName("C", "D")); EasyMock.expect(sei.getName()).andReturn(new QName("C", "D")); EasyMock.expect(rei.getBinding()).andReturn(rbi); EasyMock.expect(sboi.getName()).andReturn(new QName("E", "F")); //Causes ConcurrentModification intermittently //QName op = new QName("E", "F"); //EasyMock.expect(rbi.getOperation(op).andReturn(null); control.replay(); Server val = colocOut.isColocated(list, sep, sboi); assertEquals("Is not a colocated call", null, val); assertEquals("BindingOperation.getOperation was not called", 1, rbi.getOpCount()); control.reset(); }