Java Code Examples for org.apache.cxf.service.model.EndpointInfo#setBinding()
The following examples show how to use
org.apache.cxf.service.model.EndpointInfo#setBinding() .
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: AbstractSTSTokenTest.java From cxf with Apache License 2.0 | 6 votes |
static MessageImpl prepareMessage(Bus bus, STSClient stsClient, String serviceAddress) throws EndpointException { MessageImpl message = new MessageImpl(); message.put(SecurityConstants.STS_CLIENT, stsClient); message.put(Message.ENDPOINT_ADDRESS, serviceAddress); Exchange exchange = new ExchangeImpl(); ServiceInfo si = new ServiceInfo(); si.setName(new QName("http://www.apache.org", "ServiceName")); Service s = new ServiceImpl(si); EndpointInfo ei = new EndpointInfo(); ei.setName(new QName("http://www.apache.org", "EndpointName")); Endpoint ep = new EndpointImpl(bus, s, ei); ei.setBinding(new BindingInfo(si, null)); message.setExchange(exchange); exchange.put(Endpoint.class, ep); return message; }
Example 2
Source File: AbstractJAXRSFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
protected EndpointInfo createEndpointInfo(Service service) throws BusException { String transportId = getTransportId(); if (transportId == null && getAddress() != null) { DestinationFactory df = getDestinationFactory(); if (df == null) { DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class); df = dfm.getDestinationFactoryForUri(getAddress()); super.setDestinationFactory(df); } if (df != null) { transportId = df.getTransportIds().get(0); } } //default to http transport if (transportId == null) { transportId = "http://cxf.apache.org/transports/http"; } setTransportId(transportId); //EndpointInfo ei = new EndpointInfo(service.getServiceInfos().get(0), transportId); EndpointInfo ei = new EndpointInfo(); ei.setTransportId(transportId); ei.setName(serviceFactory.getService().getName()); ei.setAddress(getAddress()); BindingInfo bindingInfo = createBindingInfo(); ei.setBinding(bindingInfo); if (!StringUtils.isEmpty(publishedEndpointUrl)) { ei.setProperty("publishedEndpointUrl", publishedEndpointUrl); } ei.setName(service.getName()); serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINTINFO_CREATED, ei); return ei; }
Example 3
Source File: RequestPreprocessorTest.java From cxf with Apache License 2.0 | 5 votes |
private Message mockMessage(String baseAddress, String pathInfo, String query, String method, String methodHeader) { Message m = new MessageImpl(); m.put("org.apache.cxf.http.case_insensitive_queries", false); m.put("org.apache.cxf.endpoint.private", false); Exchange e = new ExchangeImpl(); m.setExchange(e); control.reset(); Endpoint endp = control.mock(Endpoint.class); e.put(Endpoint.class, endp); EasyMock.expect(endp.isEmpty()).andReturn(true).anyTimes(); EasyMock.expect(endp.get(ServerProviderFactory.class.getName())).andReturn(ServerProviderFactory.getInstance()) .anyTimes(); ServletDestination d = control.createMock(ServletDestination.class); e.setDestination(d); EndpointInfo epr = new EndpointInfo(); epr.setAddress(baseAddress); EasyMock.expect(d.getEndpointInfo()).andReturn(epr).anyTimes(); EasyMock.expect(endp.getEndpointInfo()).andReturn(epr).anyTimes(); m.put(Message.REQUEST_URI, pathInfo); m.put(Message.QUERY_STRING, query); m.put(Message.HTTP_REQUEST_METHOD, method); Map<String, List<String>> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); if (methodHeader != null) { headers.put("X-HTTP-Method-Override", Collections.singletonList(methodHeader)); } m.put(Message.PROTOCOL_HEADERS, headers); BindingInfo bi = control.createMock(BindingInfo.class); epr.setBinding(bi); EasyMock.expect(bi.getProperties()).andReturn(Collections.emptyMap()).anyTimes(); control.replay(); return m; }
Example 4
Source File: RMEndpoint.java From cxf with Apache License 2.0 | 5 votes |
void createEndpoint(org.apache.cxf.transport.Destination d, ProtocolVariation protocol) { final QName bindingQName = new QName(protocol.getWSRMNamespace(), BINDING_NAME); WrappedService service = services.get(protocol); ServiceInfo si = service.getServiceInfo(); buildBindingInfo(si, protocol); EndpointInfo aei = applicationEndpoint.getEndpointInfo(); String transportId = aei.getTransportId(); EndpointInfo ei = new EndpointInfo(si, transportId); if (d != null) { ei.setProperty(MAPAggregator.DECOUPLED_DESTINATION, d); } ei.setAddress(aei.getAddress()); ei.setName(RMUtils.getConstants(protocol.getWSRMNamespace()).getPortName()); ei.setBinding(si.getBinding(bindingQName)); // if addressing was enabled on the application endpoint by means // of the UsingAddressing element extensor, use this for the // RM endpoint also Object ua = getUsingAddressing(aei); if (null != ua) { ei.addExtensor(ua); } si.addEndpoint(ei); ei.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore); Endpoint endpoint = new WrappedEndpoint(applicationEndpoint, ei, service); if (applicationEndpoint.getEndpointInfo() != null && applicationEndpoint.getEndpointInfo().getProperties() != null) { for (String key : applicationEndpoint.getEndpointInfo().getProperties().keySet()) { endpoint.getEndpointInfo() .setProperty(key, applicationEndpoint.getEndpointInfo().getProperty(key)); } } service.setEndpoint(endpoint); endpoints.put(protocol, endpoint); }
Example 5
Source File: RMEndpointTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testCreateEndpoint() throws NoSuchMethodException, EndpointException { Method m = RMEndpoint.class.getDeclaredMethod("getUsingAddressing", new Class[] {EndpointInfo.class}); Service as = control.createMock(Service.class); EndpointInfo aei = new EndpointInfo(); ae = new EndpointImpl(null, as, aei); rme = EasyMock.createMockBuilder(RMEndpoint.class).withConstructor(manager, ae) .addMockedMethod(m).createMock(control); rme.setAplicationEndpoint(ae); rme.setManager(manager); SoapBindingInfo bi = control.createMock(SoapBindingInfo.class); aei.setBinding(bi); SoapVersion sv = Soap11.getInstance(); EasyMock.expect(bi.getSoapVersion()).andReturn(sv); String ns = "http://schemas.xmlsoap.org/wsdl/soap/"; EasyMock.expect(bi.getBindingId()).andReturn(ns); aei.setTransportId(ns); String addr = "addr"; aei.setAddress(addr); Object ua = new Object(); EasyMock.expect(rme.getUsingAddressing(aei)).andReturn(ua); control.replay(); rme.createServices(); rme.createEndpoints(null); Endpoint e = rme.getEndpoint(ProtocolVariation.RM10WSA200408); WrappedEndpoint we = (WrappedEndpoint)e; assertSame(ae, we.getWrappedEndpoint()); Service s = rme.getService(ProtocolVariation.RM10WSA200408); assertEquals(1, s.getEndpoints().size()); assertSame(e, s.getEndpoints().get(RM10Constants.PORT_NAME)); }
Example 6
Source File: ManagedRMManagerTest.java From cxf with Apache License 2.0 | 5 votes |
private Endpoint createTestEndpoint() throws Exception { ServiceInfo svci = new ServiceInfo(); svci.setName(new QName(TEST_URI, "testService")); Service svc = new ServiceImpl(svci); SoapBindingInfo binding = new SoapBindingInfo(svci, WSDLConstants.NS_SOAP11); binding.setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT); EndpointInfo ei = new EndpointInfo(); ei.setAddress(TEST_URI); ei.setName(new QName(TEST_URI, "testPort")); ei.setBinding(binding); ei.setService(svci); return new EndpointImpl(bus, svc, ei); }
Example 7
Source File: WadlGeneratorTest.java From cxf with Apache License 2.0 | 5 votes |
private Message mockMessage(String baseAddress, String pathInfo, String query, List<ClassResourceInfo> cris) throws Exception { Message m = new MessageImpl(); Exchange e = new ExchangeImpl(); e.put(Service.class, new JAXRSServiceImpl(cris)); 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); endpoint.put(ServerProviderFactory.class.getName(), ServerProviderFactory.getInstance()); 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 8
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 9
Source File: ProtobufServerFactoryBean.java From fuchsia with Apache License 2.0 | 5 votes |
protected EndpointInfo createEndpointInfo() throws BusException { String transportId = getTransportId(); if (transportId == null && getAddress() != null) { DestinationFactory df = getDestinationFactory(); if (df == null) { DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class); df = dfm.getDestinationFactoryForUri(getAddress()); } if (df != null) { transportId = df.getTransportIds().get(0); } } // default to http transport if (transportId == null) { transportId = "http://schemas.xmlsoap.org/wsdl/soap/http"; } setTransportId(transportId); EndpointInfo ei = new EndpointInfo(); ei.setTransportId(transportId); ei.setName(serviceFactory.getService().getName()); ei.setAddress(getAddress()); ei.setProperty(PROTOBUF_MESSAGE_CLASS, messageClass); BindingInfo bindingInfo = createBindingInfo(); ei.setBinding(bindingInfo); return ei; }
Example 10
Source File: ServiceUtils.java From fuchsia with Apache License 2.0 | 5 votes |
public static EndpointInfo createEndpointInfo(Bus bus, ServiceInfo serviceInfo, BindingInfo bindingInfo, String address) { String transportURI = getTransportId(bus, address); EndpointInfo endpointInfo = new EndpointInfo(serviceInfo, transportURI); if (address != null) { endpointInfo.setName(new QName(address)); endpointInfo.setAddress(address); } System.out.println("seting binding info:" + bindingInfo); endpointInfo.setBinding(bindingInfo); return endpointInfo; }
Example 11
Source File: MAPAggregatorTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testGetReplyToUsingBaseAddress() throws Exception { Message message = new MessageImpl(); Exchange exchange = new ExchangeImpl(); message.setExchange(exchange); final String localReplyTo = "/SoapContext/decoupled"; final String decoupledEndpointBase = "http://localhost:8181/cxf"; final String replyTo = decoupledEndpointBase + localReplyTo; ServiceInfo s = new ServiceInfo(); Service svc = new ServiceImpl(s); EndpointInfo ei = new EndpointInfo(); InterfaceInfo ii = s.createInterface(new QName("FooInterface")); s.setInterface(ii); ii.addOperation(new QName("fooOp")); SoapBindingInfo b = new SoapBindingInfo(s, "http://schemas.xmlsoap.org/soap/", Soap11.getInstance()); b.setTransportURI("http://schemas.xmlsoap.org/soap/http"); ei.setBinding(b); ei.setAddress("http://nowhere.com/bar/foo"); ei.setName(new QName("http://nowhere.com/port", "foo")); Bus bus = new ExtensionManagerBus(); DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class); DestinationFactory df = control.createMock(DestinationFactory.class); Destination d = control.createMock(Destination.class); bus.setExtension(dfm, DestinationFactoryManager.class); EasyMock.expect(dfm.getDestinationFactoryForUri(localReplyTo)).andReturn(df); EasyMock.expect(df.getDestination( EasyMock.anyObject(EndpointInfo.class), EasyMock.anyObject(Bus.class))).andReturn(d); EasyMock.expect(d.getAddress()).andReturn(EndpointReferenceUtils.getEndpointReference(localReplyTo)); Endpoint ep = new EndpointImpl(bus, svc, ei); exchange.put(Endpoint.class, ep); exchange.put(Bus.class, bus); exchange.setOutMessage(message); setUpMessageProperty(message, REQUESTOR_ROLE, Boolean.TRUE); message.getContextualProperty(WSAContextUtils.REPLYTO_PROPERTY); message.put(WSAContextUtils.REPLYTO_PROPERTY, localReplyTo); message.put(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY, decoupledEndpointBase); AddressingProperties maps = new AddressingProperties(); AttributedURIType id = ContextUtils.getAttributedURI("urn:uuid:12345"); maps.setMessageID(id); maps.setAction(ContextUtils.getAttributedURI("")); setUpMessageProperty(message, CLIENT_ADDRESSING_PROPERTIES, maps); control.replay(); aggregator.mediate(message, false); AddressingProperties props = (AddressingProperties)message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND); assertEquals(replyTo, props.getReplyTo().getAddress().getValue()); control.verify(); }