/** * @return the default target address */ public String getAddress() { if (defaultAddress != null) { return defaultAddress.getString(); } else if (fromEndpointReferenceType) { return getTarget().getAddress().getValue(); } return endpointInfo.getAddress(); }
static EndpointReferenceType createReference(EndpointInfo ei) { EndpointReferenceType epr = new EndpointReferenceType(); AttributedURIType address = new AttributedURIType(); address.setValue(ei.getAddress()); epr.setAddress(address); return epr; }
private void extractWsdlEprs(EndpointInfo endpoint) { //parse the EPR in wsdl List<ExtensibilityElement> portExtensors = endpoint.getExtensors(ExtensibilityElement.class); if (portExtensors != null) { Iterator<ExtensibilityElement> extensionElements = portExtensors.iterator(); QName wsaEpr = new QName(Names.WSA_NAMESPACE_NAME, "EndpointReference"); while (extensionElements.hasNext()) { ExtensibilityElement ext = extensionElements.next(); if (ext instanceof UnknownExtensibilityElement && wsaEpr.equals(ext.getElementType())) { DOMSource domSource = new DOMSource(((UnknownExtensibilityElement)ext).getElement()); W3CEndpointReference w3cEPR = new W3CEndpointReference(domSource); EndpointReferenceType ref = ProviderImpl.convertToInternal(w3cEPR); endpoint.getTarget().setMetadata(ref.getMetadata()); endpoint.getTarget().setReferenceParameters(ref.getReferenceParameters()); endpoint.getTarget().getOtherAttributes().putAll(ref.getOtherAttributes()); } } } }
public static EndpointReferenceType getEndpointReference(AttributedURIType address) { EndpointReferenceType reference = new EndpointReferenceType(); reference.setAddress(address); return reference; }
/** * Create a duplicate endpoint reference sharing all atributes * @param ref the reference to duplicate * @return EndpointReferenceType - the duplicate endpoint reference */ public static EndpointReferenceType duplicate(EndpointReferenceType ref) { EndpointReferenceType reference = new EndpointReferenceType(); reference.setMetadata(ref.getMetadata()); reference.getAny().addAll(ref.getAny()); reference.setAddress(ref.getAddress()); return reference; }
private EndpointReferenceType getTargetReference(EndpointInfo endpointInfo, EndpointReferenceType referenceType) { if (referenceType != null) { return referenceType; } EndpointReferenceType ref = new EndpointReferenceType(); AttributedURIType address = new AttributedURIType(); address.setValue(endpointInfo.getAddress()); ref.setAddress(address); if (endpointInfo.getService() != null) { setServiceAndPortName(ref, endpointInfo.getService().getName(), endpointInfo.getName().getLocalPart()); } return ref; } }
/** * Check for NONE ReplyTo value in request-response MEP * @param message the current message * @param maps the incoming MAPs */ private void checkReplyTo(Message message, AddressingProperties maps) { // if ReplyTo address is none then 202 response status is expected // However returning a fault is more appropriate for request-response MEP if (!message.getExchange().isOneWay() && !MessageUtils.isPartialResponse(message) && ContextUtils.isNoneAddress(maps.getReplyTo())) { String reason = MessageFormat.format(BUNDLE.getString("REPLYTO_NOT_SUPPORTED_MSG"), maps.getReplyTo().getAddress().getValue()); throw new SoapFault(reason, new QName(Names.WSA_NAMESPACE_NAME, Names.WSA_NONE_ADDRESS)); } }
protected void grantSubscriptionManagerReference(SubscriptionTicket ticket, SubscriptionTicketGrantingResponse response) { EndpointReferenceType subscriptionManagerReference = new EndpointReferenceType(); subscriptionManagerReference.setAddress(getSubscriptionManagerAddress()); // generate a ID for this subscription UUID uuid = UUID.randomUUID(); JAXBElement<String> idqn = new JAXBElement<>(new QName(subscriptionIdNamespace, subscriptionIdElementName), String.class, uuid.toString()); subscriptionManagerReference.setReferenceParameters(new ReferenceParametersType()); subscriptionManagerReference.getReferenceParameters().getAny().add(idqn); ticket.setUuid(uuid); response.setSubscriptionManagerReference(subscriptionManagerReference); response.setUUID(uuid); }
/** * Convert from 2004/08 EndpointReferenceType to 2005/08 * EndpointReferenceType. * * @param exposed the 2004/08 EndpointReferenceType * @return an equivalent 2005/08 EndpointReferenceType */ public static EndpointReferenceType convert( org.apache.cxf.ws.addressing.v200408.EndpointReferenceType exposed) { EndpointReferenceType internal = ContextUtils.WSA_OBJECT_FACTORY.createEndpointReferenceType(); internal.setAddress(convert(exposed.getAddress())); internal.setReferenceParameters( convert(exposed.getReferenceParameters())); ServiceNameType serviceName = exposed.getServiceName(); AttributedQName portName = exposed.getPortType(); if (serviceName != null && portName != null) { EndpointReferenceUtils.setServiceAndPortName(internal, serviceName.getValue(), portName.getValue().getLocalPart()); } // no direct analogue for ReferenceProperties addAll(internal.getAny(), exposed.getAny()); putAll(internal.getOtherAttributes(), exposed.getOtherAttributes()); return internal; }
private String extractStringElementFromAny(QName elementQName, EndpointReferenceType epr) { String elementStringValue = null; if (null != epr.getReferenceParameters()) { for (Object o : epr.getReferenceParameters().getAny()) { if (o instanceof JAXBElement) { JAXBElement<?> el = (JAXBElement<?>)o; if (el.getName().equals(elementQName)) { elementStringValue = (String)el.getValue(); } } } } return elementStringValue; } }
conduitInitiatorMgr.getConduitInitiator(transportID); if (conduitInitiator != null) { String add = (String)message.get(Message.ENDPOINT_ADDRESS); String basePath = (String)message.get(Message.BASE_PATH); if (StringUtils.isEmpty(add) || add.equals(ei.getAddress())) { c = conduitInitiator.getConduit(ei); replaceEndpointAddressPropertyIfNeeded(message, add, c); } else { EndpointReferenceType epr = new EndpointReferenceType(); AttributedURIType ad = new AttributedURIType(); ad.setValue(StringUtils.isEmpty(basePath) ? add : basePath); epr.setAddress(ad); c = conduitInitiator.getConduit(ei, epr); exchange.get(MessageObserver.class); if (observer != null) { c.setMessageObserver(observer); + ei.getAddress()); if (c != null && c.getTarget() != null && c.getTarget().getAddress() != null) { replaceEndpointAddressPropertyIfNeeded(message, c.getTarget().getAddress().getValue(), c);
Conduit c = message.get(Conduit.class); if (c == null && message.getExchange() != null && message.getExchange().getOutMessage() != null && message.getExchange().getOutMessage() != message) { c = message.getExchange().getOutMessage().get(Conduit.class); for (Conduit c2 : conduits) { if (c2.getTarget() == null || c2.getTarget().getAddress() == null || c2.getTarget().getAddress().getValue() == null) { continue; String conduitAddress = c2.getTarget().getAddress().getValue(); EndpointInfo ei = endpoint.getEndpointInfo(); String actualAddress = ei.getAddress(); String messageAddress = (String)message.get(Message.ENDPOINT_ADDRESS); || c2.getTarget().getAddress() == null || c2.getTarget().getAddress().getValue() == null) { return c2;
protected Conduit getNextConduit(Message message) { Conduit answer = null; Exchange exchange = message.getExchange(); EndpointInfo ei = endpoint.getEndpointInfo(); String address = loadBalanceStrategy.getNextAlternateAddress(); if (overrideAddress(message)) { message.put(Message.ENDPOINT_ADDRESS, address); ConduitInitiatorManager conduitInitiatorMgr = exchange.getBus() .getExtension(ConduitInitiatorManager.class); if (conduitInitiatorMgr != null) { conduitInitiatorMgr.getConduitInitiatorForUri(address); if (conduitInitiator != null) { EndpointReferenceType epr = new EndpointReferenceType(); AttributedURIType ad = new AttributedURIType(); ad.setValue(address); epr.setAddress(ad); answer = conduitInitiator.getConduit(ei, epr, exchange.getBus()); exchange.get(MessageObserver.class); if (observer != null) { answer.setMessageObserver(observer); + ei.getAddress());
EndpointInfo ei = endpoint.getEndpointInfo(); String add = (String)message.get(Message.ENDPOINT_ADDRESS); String basePath = (String)message.get(Message.BASE_PATH); if (StringUtils.isEmpty(add) || add.equals(ei.getAddress())) { c = conduitInitiator.getConduit(ei, exchange.getBus()); replaceEndpointAddressPropertyIfNeeded(message, add, c); } else { EndpointReferenceType epr = new EndpointReferenceType(); AttributedURIType ad = new AttributedURIType(); ad.setValue(StringUtils.isEmpty(basePath) ? add : basePath); epr.setAddress(ad); c = conduitInitiator.getConduit(ei, epr, exchange.getBus()); exchange.get(MessageObserver.class); if (observer != null) { c.setMessageObserver(observer);
Conduit c = findCompatibleConduit(message); if (c == null) { Exchange exchange = message.getExchange(); EndpointInfo ei = endpoint.getEndpointInfo(); String transportID = ei.getTransportId(); try { ConduitInitiatorManager conduitInitiatorMgr = exchange.getBus() .getExtension(ConduitInitiatorManager.class); if (conduitInitiatorMgr != null) { } else { getLogger().warning("ConduitInitiator not found: " + ei.getAddress()); if (c != null && c.getTarget() != null && c.getTarget().getAddress() != null) { replaceEndpointAddressPropertyIfNeeded(message, c.getTarget().getAddress().getValue(), c); message.resetContextCache(); message.put(Conduit.class, c); return c;
public static String getEndpointAddress(Message m) { String address = null; Destination d = m.getExchange().getDestination(); if (d != null) { if (d instanceof AbstractHTTPDestination) { EndpointInfo ei = ((AbstractHTTPDestination)d).getEndpointInfo(); HttpServletRequest request = (HttpServletRequest)m.get(AbstractHTTPDestination.HTTP_REQUEST); Object property = request != null ? request.getAttribute("org.apache.cxf.transport.endpoint.address") : null; address = property != null ? property.toString() : ei.getAddress(); } else { address = m.containsKey(Message.BASE_PATH) ? (String)m.get(Message.BASE_PATH) : d.getAddress().getAddress().getValue(); } } else { address = (String)m.get(Message.ENDPOINT_ADDRESS); } if (address.startsWith("http") && address.endsWith("//")) { address = address.substring(0, address.length() - 1); } return address; }
private EndpointReferenceType getReplyTo(Message message, EndpointReferenceType originalReplyTo) { Exchange exchange = message.getExchange(); Endpoint info = exchange.getEndpoint(); if (info == null) { return originalReplyTo; EndpointInfo ei = info.getEndpointInfo(); Destination dest = ei.getProperty(DECOUPLED_DESTINATION, Destination.class); if (dest == null) { dest = createDecoupledDestination(message); if (dest != null) { info.getEndpointInfo().setProperty(DECOUPLED_DESTINATION, dest); final String replyTo = dest.getAddress().getAddress().getValue(); if (replyTo.startsWith("/")) { String debase = (String)message.getContextualProperty(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY); if (debase != null) { return EndpointReferenceUtils.getEndpointReference(debase + replyTo);
@Override public void handleMessage(Message message) throws Fault { TimeMeasure timeMeasure = message.getExchange().get(TimeMeasure.class); if (timeMeasure == null) { if (!this.errorLogged) { LOG.warn("Invalid setup - no TimeMeasure present!"); this.errorLogged = true; } return; } Throwable exception = message.getContent(Exception.class); if (exception == null) { timeMeasure.succeed(); } Conduit conduit = message.get(Conduit.class); EndpointReferenceType target = conduit.getTarget(); String url = target.getAddress().getValue(); timeMeasure.log(LOG, url); }
public Conduit getBackChannel(Message inMessage) throws IOException { Bus bus = inMessage.getExchange().getBus(); //this is a response targeting a decoupled endpoint. Treat it as a oneway so //we don't wait for a response. inMessage.getExchange().setOneWay(true); ConduitInitiator conduitInitiator = bus.getExtension(ConduitInitiatorManager.class) .getConduitInitiatorForUri(reference.getAddress().getValue()); if (conduitInitiator != null) { Conduit c = conduitInitiator.getConduit(ei, reference, bus); //ensure decoupled back channel input stream is closed c.setMessageObserver(new MessageObserver() { public void onMessage(Message m) { InputStream is = m.getContent(InputStream.class); if (is != null) { try { is.close(); } catch (Exception e) { //ignore } } } }); return c; } return null; } public MessageObserver getMessageObserver() {
private void dispatchViaPipe(final Message message) throws IOException { final LocalConduit conduit = this; final Exchange exchange = message.getExchange(); if (destination.getMessageObserver() == null) { throw new IllegalStateException("Local destination does not have a MessageObserver on address " + destination.getAddress().getAddress().getValue()); } AbstractWrappedOutputStream cout = new LocalConduitOutputStream(conduit, exchange, message); message.setContent(OutputStream.class, cout); }