/** * @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; }
public AttributedURIType getSubscriptionManagerAddress() { AttributedURIType ret = new AttributedURIType(); ret.setValue(url); return ret; }
/** * Set the address of the provided endpoint reference. * @param ref - the endpoint reference * @param address - the address */ public static void setAddress(EndpointReferenceType ref, String address) { AttributedURIType a = new AttributedURIType(); a.setValue(address); ref.setAddress(a); } /**
private static void setAction(AddressingProperties maps, String action) { AttributedURIType actionURI = new AttributedURIType(); actionURI.setValue(action); maps.setAction(actionURI); } }
public void handleMessage(Message message) throws Fault { String action = (String)message.get(SoapBindingConstants.SOAP_ACTION); if (action == null) { AddressingProperties inProps = (AddressingProperties)message .getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND); if (inProps != null && inProps.getAction() != null) { action = inProps.getAction().getValue(); } } if ("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get".equals(action) || "http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata/Request".equals(action)) { message.remove(AssertionInfoMap.class.getName()); Exchange ex = message.getExchange(); Endpoint endpoint = createEndpoint(message); ex.put(Endpoint.class, endpoint); ex.put(Service.class, endpoint.getService()); ex.put(org.apache.cxf.binding.Binding.class, endpoint.getBinding()); ex.put(BindingOperationInfo.class, endpoint.getBinding().getBindingInfo() .getOperation(new QName("http://mex.ws.cxf.apache.org/", "Get2004"))); ex.remove(BindingOperationInfo.class); message.put(MAPAggregator.ACTION_VERIFIED, Boolean.TRUE); message.getInterceptorChain().add(endpoint.getInInterceptors()); message.getInterceptorChain().add(endpoint.getBinding().getInInterceptors()); } }
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; }
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);
@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); }
if (isServer) { AddressingProperties inMaps = RMContextUtils.retrieveMAPs(message, false, false); inMaps.exposeAs(config.getAddressingNamespace()); acksTo = RMUtils.createReference(inMaps.getTo().getValue()); to = inMaps.getReplyTo(); source.getReliableEndpoint().getServant().setUnattachedIdentifier(inSeqId); relatesTo = (new org.apache.cxf.ws.addressing.ObjectFactory()).createRelatesToType(); to = RMUtils.createReference(maps.getTo().getValue()); acksTo = maps.getReplyTo(); if (RMUtils.getAddressingConstants().getNoneURI().equals(acksTo.getAddress().getValue())) { Endpoint ei = message.getExchange().getEndpoint(); org.apache.cxf.transport.Destination dest = ei == null ? null : ei.getEndpointInfo() .getProperty(MAPAggregator.DECOUPLED_DESTINATION, org.apache.cxf.transport.Destination.class); if (null == dest) { if (ContextUtils.isGenericAddress(to)) { org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message( "CREATE_SEQ_ANON_TARGET", LOG, to != null && to.getAddress() != null ? to.getAddress().getValue() : null); LOG.log(Level.INFO, msg.toString()); throw new RMException(msg); context.put(key, message.getContextualProperty(key));
public Conduit getBackChannel(Message inMessage) throws IOException { if (ContextUtils.isNoneAddress(reference)) { return null; } 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; }
private EndpointReferenceType getReplyTo(Message message, EndpointReferenceType originalReplyTo) { Exchange exchange = message.getExchange(); Endpoint info = exchange.getEndpoint(); if (info == null) { return originalReplyTo; 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);
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); }
/** * 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)); } }
public Conduit getBackChannel(Message inMessage, Message partialResponse, EndpointReferenceType address) throws IOException { Bus bus = inMessage.getExchange().get(Bus.class); //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); //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() {
&& maps.getRelatesTo() != null && !Names.WSA_UNSPECIFIED_RELATIONSHIP.equals(maps.getRelatesTo().getValue()) && isRelationshipReply(maps.getRelatesTo())) { synchronized (correlatedExchange) { message.setExchange(correlatedExchange); Message outmsg = message.getExchange().getOutMessage(); || !outp.getMessageID().getValue().equals(maps.getRelatesTo().getValue())) { Message m = message.getExchange().getOutMessage(); Exchange ex = uncorrelatedExchanges.get(maps.getMessageID().getValue()); if (ex == message.getExchange()) { uncorrelatedExchanges.remove(maps.getMessageID().getValue()); LOG.log(Level.WARNING, "RESPONSE_NOT_USING_WSADDRESSING"); && (Names.WSA_DEFAULT_FAULT_ACTION.equals(maps.getAction().getValue()) || Names.WSA_DEFAULT_SOAP_FAULT_ACTION.equals(maps.getAction().getValue()) || "http://docs.oasis-open.org/wsrf/fault".equals(maps.getAction().getValue()))) { if (maps != null) { uncorrelatedExchanges.remove(maps.getMessageID().getValue());
private void handleAddressing(SoapMessage message) { final AddressingProperties maps = (AddressingProperties) message.getContextualProperty( JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND); if (maps == null) { return; final EndpointReferenceType rpl = maps.getReplyTo(); if (rpl == null) { return; final AttributedURIType addr = rpl.getAddress(); if (addr == null) { return; final String replyTo = addr.getValue(); final Exchange exchange = message.getExchange(); if (exchange.getDestination() instanceof JMSDestination) { ContextUtils.storePartialResponseSent(message); if (!exchange.isOneWay()) { exchange.setOneWay(true); addr.setValue(Names.WSA_ANONYMOUS_ADDRESS);
public void handleMessage(SoapMessage message) throws Fault { AddressingProperties inProps = (AddressingProperties)message .getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND); AddressingProperties outProps = (AddressingProperties)message .getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND); if (inProps != null) { if (outProps == null) { outProps = new AddressingProperties(inProps.getNamespaceURI()); } AttributedURIType action = new AttributedURIType(); action.setValue(inProps.getAction().getValue().replace("/RST/", "/RSTR/")); outProps.setAction(action); message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND, outProps); } }
private void updateOutputAction(String append) { AddressingProperties p = ContextUtils.retrieveMAPs(PhaseInterceptorChain.getCurrentMessage(), false, false); AddressingProperties pout = new AddressingProperties(); AttributedURIType action = new AttributedURIType(); action.setValue(p.getAction().getValue() + append); pout.exposeAs(p.getNamespaceURI()); pout.setAction(action); ContextUtils.storeMAPs(pout, PhaseInterceptorChain.getCurrentMessage(), true); }
@Override public void handleMessage(Message pMessage) throws Fault { AttributedURIType uri = new AttributedURIType(); uri.setValue(getWSAddressingToUri()); AddressingProperties maps = new AddressingProperties(); maps.setTo(uri); pMessage.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, maps); }