Java Code Examples for org.apache.cxf.service.model.EndpointInfo#getBinding()
The following examples show how to use
org.apache.cxf.service.model.EndpointInfo#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: MAPAggregatorImpl.java From cxf with Apache License 2.0 | 6 votes |
/** * Determine if the use of addressing is indicated by the presence of a * the usingAddressing attribute. * * @param message the current message * @pre message is outbound * @pre requestor role */ private boolean hasUsingAddressing(Message message) { boolean ret = false; Endpoint endpoint = message.getExchange().getEndpoint(); if (null != endpoint) { Boolean b = (Boolean)endpoint.get(USING_ADDRESSING); if (null == b) { EndpointInfo endpointInfo = endpoint.getEndpointInfo(); List<ExtensibilityElement> endpointExts = endpointInfo != null ? endpointInfo .getExtensors(ExtensibilityElement.class) : null; List<ExtensibilityElement> bindingExts = endpointInfo != null && endpointInfo.getBinding() != null ? endpointInfo .getBinding().getExtensors(ExtensibilityElement.class) : null; List<ExtensibilityElement> serviceExts = endpointInfo != null && endpointInfo.getService() != null ? endpointInfo .getService().getExtensors(ExtensibilityElement.class) : null; ret = hasUsingAddressing(endpointExts) || hasUsingAddressing(bindingExts) || hasUsingAddressing(serviceExts); b = ret ? Boolean.TRUE : Boolean.FALSE; endpoint.put(USING_ADDRESSING, b); } else { ret = b.booleanValue(); } } return ret; }
Example 2
Source File: RMEndpoint.java From cxf with Apache License 2.0 | 6 votes |
Object getUsingAddressing(EndpointInfo endpointInfo) { if (null == endpointInfo) { return null; } Object ua = null; List<ExtensibilityElement> exts = endpointInfo.getExtensors(ExtensibilityElement.class); ua = getUsingAddressing(exts); if (null != ua) { return ua; } exts = endpointInfo.getBinding() != null ? endpointInfo.getBinding() .getExtensors(ExtensibilityElement.class) : null; ua = getUsingAddressing(exts); if (null != ua) { return ua; } exts = endpointInfo.getService() != null ? endpointInfo.getService() .getExtensors(ExtensibilityElement.class) : null; ua = getUsingAddressing(exts); if (null != ua) { return ua; } return ua; }
Example 3
Source File: CorbaDestination.java From cxf with Apache License 2.0 | 6 votes |
public CorbaDestination(EndpointInfo ei, OrbConfig config, CorbaTypeMap tm) { address = ei.getExtensor(AddressType.class); binding = ei.getBinding(); reference = new EndpointReferenceType(); AttributedURIType addr = new AttributedURIType(); addr.setValue(address.getLocation()); reference.setAddress(addr); endpointInfo = ei; orbConfig = config; if (tm != null) { typeMap = tm; } else { typeMap = TypeMapCache.get(binding.getService()); } PolicyType policy = ei.getExtensor(PolicyType.class); if (policy != null) { poaName = policy.getPoaname(); isPersistent = policy.isPersistent(); serviceId = policy.getServiceid(); } }
Example 4
Source File: JMSEndpointWSDLUtil.java From cxf with Apache License 2.0 | 6 votes |
public static <T> T getWSDLExtensor(EndpointInfo ei, Class<T> cls) { ServiceInfo si = ei.getService(); BindingInfo bi = ei.getBinding(); Object o = ei.getExtensor(cls); if (o == null && si != null) { o = si.getExtensor(cls); } if (o == null && bi != null) { o = bi.getExtensor(cls); } if (o == null) { return null; } if (cls.isInstance(o)) { return cls.cast(o); } return null; }
Example 5
Source File: JMSEndpoint.java From cxf with Apache License 2.0 | 6 votes |
/** * @param endpointInfo * @param endpointUri */ public JMSEndpoint(EndpointInfo endpointInfo, String endpointUri) { this.jmsVariant = JMSEndpoint.QUEUE; if (endpointInfo != null) { JMSEndpointWSDLUtil.retrieveWSDLInformation(this, endpointInfo); } if (!(StringUtils.isEmpty(endpointUri) || "jms://".equals(endpointUri) || !endpointUri.startsWith("jms"))) { this.endpointUri = endpointUri; JMSURIParser parsed = new JMSURIParser(endpointUri); setJmsVariant(parsed.getVariant()); this.destinationName = parsed.getDestination(); Map<String, Object> query = parsed.parseQuery(); configureProperties(query); // Use the properties like e.g. from JAXWS properties with "jms." prefix Map<String, Object> jmsProps = new HashMap<>(); if (endpointInfo != null) { getJaxWsJmsProps(endpointInfo.getProperties(), jmsProps); } if (endpointInfo != null && endpointInfo.getBinding() != null) { getJaxWsJmsProps(endpointInfo.getBinding().getProperties(), jmsProps); } configureProperties(jmsProps); } }
Example 6
Source File: ClientMtomXopTest.java From cxf with Apache License 2.0 | 5 votes |
private <T> T createPort(QName serviceName, QName portName, Class<T> serviceEndpointInterface, boolean enableMTOM, boolean installInterceptors) throws Exception { ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean(); Bus bus = getStaticBus(); serviceFactory.setBus(bus); serviceFactory.setServiceName(serviceName); serviceFactory.setServiceClass(serviceEndpointInterface); serviceFactory.setWsdlURL(ClientMtomXopTest.class.getResource("/wsdl/mtom_xop.wsdl")); Service service = serviceFactory.create(); EndpointInfo ei = service.getEndpointInfo(portName); JaxWsEndpointImpl jaxwsEndpoint = new JaxWsEndpointImpl(bus, service, ei); SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding(), jaxwsEndpoint); jaxWsSoapBinding.setMTOMEnabled(enableMTOM); if (installInterceptors) { //jaxwsEndpoint.getBinding().getInInterceptors().add(new TestMultipartMessageInterceptor()); jaxwsEndpoint.getBinding().getOutInterceptors().add(new TestAttachmentOutInterceptor()); } jaxwsEndpoint.getBinding().getInInterceptors().add(new LoggingInInterceptor()); jaxwsEndpoint.getBinding().getOutInterceptors().add(new LoggingOutInterceptor()); Client client = new ClientImpl(bus, jaxwsEndpoint); InvocationHandler ih = new JaxWsClientProxy(client, jaxwsEndpoint.getJaxwsBinding()); Object obj = Proxy .newProxyInstance(serviceEndpointInterface.getClassLoader(), new Class[] {serviceEndpointInterface, BindingProvider.class}, ih); updateAddressPort(obj, PORT); return serviceEndpointInterface.cast(obj); }
Example 7
Source File: MAPAggregatorTest.java From cxf with Apache License 2.0 | 5 votes |
private void setUpUsingAddressing(Message message, Exchange exchange, boolean usingAddressing) { setUpMessageExchange(message, exchange); Endpoint endpoint = control.createMock(Endpoint.class); endpoint.getOutInterceptors(); EasyMock.expectLastCall().andReturn(new ArrayList<Interceptor<? extends Message>>()).anyTimes(); setUpExchangeGet(exchange, Endpoint.class, endpoint); EndpointInfo endpointInfo = control.createMock(EndpointInfo.class); endpoint.getEndpointInfo(); EasyMock.expectLastCall().andReturn(endpointInfo).anyTimes(); List<ExtensibilityElement> endpointExts = new ArrayList<>(); endpointInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class)); EasyMock.expectLastCall().andReturn(endpointExts).anyTimes(); BindingInfo bindingInfo = control.createMock(BindingInfo.class); endpointInfo.getBinding(); EasyMock.expectLastCall().andReturn(bindingInfo).anyTimes(); bindingInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class)); EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST).anyTimes(); ServiceInfo serviceInfo = control.createMock(ServiceInfo.class); endpointInfo.getService(); EasyMock.expectLastCall().andReturn(serviceInfo).anyTimes(); serviceInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class)); EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST).anyTimes(); ExtensibilityElement ext = control.createMock(ExtensibilityElement.class); if (usingAddressing) { QName elementType = usingAddressing ? Names.WSAW_USING_ADDRESSING_QNAME : new QName(SOAP_NAMESPACE, "encodingStyle"); ext.getElementType(); EasyMock.expectLastCall().andReturn(elementType).anyTimes(); endpointExts.add(ext); } }
Example 8
Source File: RMEndpoint.java From cxf with Apache License 2.0 | 5 votes |
void setPolicies(Message message) { // use same WS-policies as for application endpoint PolicyEngine engine = manager.getBus().getExtension(PolicyEngine.class); if (null == engine || !engine.isEnabled()) { return; } for (Endpoint endpoint : endpoints.values()) { EndpointInfo ei = endpoint.getEndpointInfo(); EndpointPolicy epi = null == conduit ? engine.getServerEndpointPolicy(applicationEndpoint.getEndpointInfo(), null, message) : engine.getClientEndpointPolicy(applicationEndpoint.getEndpointInfo(), conduit, message); if (conduit != null) { engine.setClientEndpointPolicy(ei, epi); } else { engine.setServerEndpointPolicy(ei, epi); } EffectivePolicyImpl effectiveOutbound = new EffectivePolicyImpl(); effectiveOutbound.initialise(epi, engine, false, false, message); EffectivePolicyImpl effectiveInbound = new EffectivePolicyImpl(); effectiveInbound.initialise(epi, engine, true, false, message); BindingInfo bi = ei.getBinding(); Collection<BindingOperationInfo> bois = bi.getOperations(); for (BindingOperationInfo boi : bois) { engine.setEffectiveServerRequestPolicy(ei, boi, effectiveInbound); engine.setEffectiveServerResponsePolicy(ei, boi, effectiveOutbound); engine.setEffectiveClientRequestPolicy(ei, boi, effectiveOutbound); engine.setEffectiveClientResponsePolicy(ei, boi, effectiveInbound); } } // TODO: FaultPolicy (SequenceFault) }
Example 9
Source File: SoapTransportFactory.java From cxf with Apache License 2.0 | 5 votes |
public Destination getDestination(EndpointInfo ei, Bus bus) throws IOException { String address = ei.getAddress(); BindingInfo bi = ei.getBinding(); String transId = ei.getTransportId(); if (bi instanceof SoapBindingInfo) { transId = ((SoapBindingInfo)bi).getTransportURI(); if (transId == null) { transId = ei.getTransportId(); } } DestinationFactory destinationFactory; try { DestinationFactoryManager mgr = bus.getExtension(DestinationFactoryManager.class); if (StringUtils.isEmpty(address) || address.startsWith("http") || address.startsWith("jms") || address.startsWith("soap.udp") || address.startsWith("/")) { destinationFactory = mgr.getDestinationFactory(mapTransportURI(transId, address)); } else { destinationFactory = mgr.getDestinationFactoryForUri(address); } if (destinationFactory == null) { throw new IOException("Could not find destination factory for transport " + transId); } return destinationFactory.getDestination(ei, bus); } catch (BusException e) { IOException ex = new IOException("Could not find destination factory for transport " + transId); ex.initCause(e); throw ex; } }
Example 10
Source File: SoapTransportFactory.java From cxf with Apache License 2.0 | 5 votes |
public Conduit getConduit(EndpointInfo ei, EndpointReferenceType target, Bus bus) throws IOException { String address = target == null ? ei.getAddress() : target.getAddress().getValue(); BindingInfo bi = ei.getBinding(); String transId = ei.getTransportId(); if (bi instanceof SoapBindingInfo) { transId = ((SoapBindingInfo)bi).getTransportURI(); if (transId == null) { transId = ei.getTransportId(); } } ConduitInitiator conduitInit; try { ConduitInitiatorManager mgr = bus.getExtension(ConduitInitiatorManager.class); if (StringUtils.isEmpty(address) || address.startsWith("http") || address.startsWith("jms") || address.startsWith("soap.udp")) { conduitInit = mgr.getConduitInitiator(mapTransportURI(transId, address)); } else { conduitInit = mgr.getConduitInitiatorForUri(address); } if (conduitInit == null) { throw new RuntimeException(String.format(CANNOT_GET_CONDUIT_ERROR, address, transId)); } return conduitInit.getConduit(ei, target, bus); } catch (BusException e) { throw new RuntimeException(String.format(CANNOT_GET_CONDUIT_ERROR, address, transId)); } }
Example 11
Source File: EndpointSelectionInterceptor.java From cxf with Apache License 2.0 | 5 votes |
protected Endpoint selectEndpoint(Message message, Set<Endpoint> eps) { SoapVersion sv = ((SoapMessage)message).getVersion(); for (Endpoint e : eps) { EndpointInfo ei = e.getEndpointInfo(); BindingInfo binding = ei.getBinding(); if (binding instanceof SoapBindingInfo && ((SoapBindingInfo)binding).getSoapVersion().equals(sv)) { return e; } } return null; }
Example 12
Source File: ClientImpl.java From cxf with Apache License 2.0 | 5 votes |
private EndpointInfo findEndpoint(Service svc, QName port) { if (port != null) { EndpointInfo epfo = svc.getEndpointInfo(port); if (epfo == null) { throw new IllegalArgumentException("The service " + svc.getName() + " does not have an endpoint " + port + "."); } return epfo; } for (ServiceInfo svcfo : svc.getServiceInfos()) { for (EndpointInfo e : svcfo.getEndpoints()) { BindingInfo bfo = e.getBinding(); String bid = bfo.getBindingId(); if ("http://schemas.xmlsoap.org/wsdl/soap/".equals(bid) || "http://schemas.xmlsoap.org/wsdl/soap12/".equals(bid)) { for (Object o : bfo.getExtensors().get()) { try { String s = (String)o.getClass().getMethod("getTransportURI").invoke(o); if (s != null && s.endsWith("http")) { return e; } } catch (Throwable t) { //ignore } } } } } throw new UnsupportedOperationException( "Only document-style SOAP 1.1 and 1.2 http are supported " + "for auto-selection of endpoint; none were found."); }
Example 13
Source File: ServiceProcessor.java From cxf with Apache License 2.0 | 4 votes |
private JavaPort processPort(JavaModel model, ServiceInfo si, EndpointInfo port) throws ToolException { BindingInfo binding = port.getBinding(); String portType = binding.getInterface().getName().getLocalPart(); JavaInterface intf = PortTypeProcessor.getInterface(context, si, binding.getInterface()); JavaPort jport = new JavaPort(NameUtil.mangleNameToClassName(port.getName().getLocalPart())); jport.setPackageName(intf.getPackageName()); jport.setPortName(port.getName().getLocalPart()); jport.setBindingAdress(port.getAddress()); jport.setBindingName(binding.getName().getLocalPart()); jport.setPortType(portType); jport.setInterfaceClass(intf.getName()); bindingType = getBindingType(binding); if (bindingType == null) { org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("BINDING_SPECIFY_ONE_PROTOCOL", LOG, binding.getName()); throw new ToolException(msg); } if (isSoapBinding()) { SoapBinding spbd = SOAPBindingUtil.getProxy(SoapBinding.class, this.bindingObj); jport.setStyle(SOAPBindingUtil.getSoapStyle(spbd.getStyle())); jport.setTransURI(spbd.getTransportURI()); } Collection<BindingOperationInfo> operations = binding.getOperations(); for (BindingOperationInfo bop : operations) { processOperation(model, bop, binding); } jport.setJavaDoc(port.getDocumentation()); JAXWSBinding bind = port.getExtensor(JAXWSBinding.class); if (bind != null) { jport.setMethodName(bind.getMethodName()); jport.setJavaDoc(bind.getMethodJavaDoc()); } return jport; }
Example 14
Source File: SoapTransportFactory.java From cxf with Apache License 2.0 | 4 votes |
public void createPortExtensors(Bus b, EndpointInfo ei, Service service) { if (ei.getBinding() instanceof SoapBindingInfo) { SoapBindingInfo bi = (SoapBindingInfo)ei.getBinding(); createSoapExtensors(b, ei, bi, bi.getSoapVersion() instanceof Soap12); } }
Example 15
Source File: WSDLServiceBuilderTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testExtensions() throws Exception { setUpWSDL("hello_world_ext.wsdl", 0); String ns = "http://apache.org/hello_world_soap_http"; QName pingMeOpName = new QName(ns, "pingMe"); QName greetMeOpName = new QName(ns, "greetMe"); QName faultName = new QName(ns, "pingMeFault"); // portType extensions InterfaceInfo ii = serviceInfo.getInterface(); assertEquals(2, ii.getExtensionAttributes().size()); assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_BOOLEAN)); assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_STRING)); assertEquals(1, ii.getExtensors(UnknownExtensibilityElement.class).size()); assertEquals(EXTENSION_ELEM, ii.getExtensor(UnknownExtensibilityElement.class).getElementType()); // portType/operation extensions OperationInfo oi = ii.getOperation(pingMeOpName); assertPortTypeOperationExtensions(oi, true); assertPortTypeOperationExtensions(ii.getOperation(greetMeOpName), false); // portType/operation/[input|output|fault] extensions assertPortTypeOperationMessageExtensions(oi, true, true, faultName); assertPortTypeOperationMessageExtensions(ii.getOperation(greetMeOpName), false, true, null); // service extensions assertEquals(1, serviceInfo.getExtensionAttributes().size()); assertNotNull(serviceInfo.getExtensionAttribute(EXTENSION_ATTR_STRING)); assertEquals(1, serviceInfo.getExtensors(UnknownExtensibilityElement.class).size()); assertEquals(EXTENSION_ELEM, serviceInfo.getExtensor(UnknownExtensibilityElement.class).getElementType()); // service/port extensions EndpointInfo ei = serviceInfo.getEndpoints().iterator().next(); assertEquals(1, ei.getExtensionAttributes().size()); assertNotNull(ei.getExtensionAttribute(EXTENSION_ATTR_STRING)); assertEquals(1, ei.getExtensors(UnknownExtensibilityElement.class).size()); assertEquals(EXTENSION_ELEM, ei.getExtensor(UnknownExtensibilityElement.class).getElementType()); // binding extensions BindingInfo bi = ei.getBinding(); // REVISIT: bug in wsdl4j? // getExtensionAttributes on binding element returns an empty map // assertEquals(1, bi.getExtensionAttributes().size()); // assertNotNull(bi.getExtensionAttribute(EXTENSION_ATTR_STRING)); assertEquals(1, bi.getExtensors(UnknownExtensibilityElement.class).size()); assertEquals(EXTENSION_ELEM, bi.getExtensor(UnknownExtensibilityElement.class).getElementType()); // binding/operation extensions BindingOperationInfo boi = bi.getOperation(pingMeOpName); assertBindingOperationExtensions(boi, true); assertBindingOperationExtensions(bi.getOperation(greetMeOpName), false); // binding/operation/[input|output|fault] extensions assertBindingOperationMessageExtensions(boi, true, true, faultName); assertBindingOperationMessageExtensions(bi.getOperation(greetMeOpName), false, true, null); control.verify(); }