use of org.apache.cxf.transport.Destination in project cxf by apache.
the class LocalTransportFactory method getDestination.
protected Destination getDestination(EndpointInfo ei, EndpointReferenceType reference, Bus bus) throws IOException {
Destination d = null;
String addr = reference.getAddress().getValue();
if (addr == null) {
AddressType tp = ei.getExtensor(AddressType.class);
if (tp != null) {
addr = tp.getLocation();
}
}
if (addr == null) {
addr = NULL_ADDRESS;
}
d = destinations.get(addr);
if (d == null) {
d = createDestination(ei, reference, bus);
Destination tmpD = destinations.putIfAbsent(addr, d);
if (tmpD != null) {
d = tmpD;
}
}
return d;
}
use of org.apache.cxf.transport.Destination in project cxf by apache.
the class WebSocketTransportFactoryTest method testGetDestination.
@Test
public void testGetDestination() throws Exception {
Bus bus = BusFactory.getDefaultBus();
EndpointInfo ei = new EndpointInfo();
ei.setAddress("ws://localhost:8888/bar/foo");
WebSocketTransportFactory factory = bus.getExtension(WebSocketTransportFactory.class);
assertNotNull(factory);
Destination dest = factory.getDestination(ei, bus);
assertNotNull(dest);
}
use of org.apache.cxf.transport.Destination in project cxf by apache.
the class MAPAggregatorImpl method addRoleSpecific.
/**
* Add MAPs which are specific to the requestor or responder role.
*
* @param maps the MAPs being assembled
* @param message the current message
* @param isRequestor true iff the current messaging role is that of
* requestor
* @param isFault true if a fault is being mediated
*/
private void addRoleSpecific(AddressingProperties maps, Message message, boolean isRequestor, boolean isFault) {
if (isRequestor) {
Exchange exchange = message.getExchange();
// add request-specific MAPs
boolean isOneway = exchange.isOneWay();
boolean isOutbound = ContextUtils.isOutbound(message);
// To
if (maps.getTo() == null) {
Conduit conduit = null;
if (isOutbound) {
conduit = ContextUtils.getConduit(null, message);
}
String s = (String) message.get(Message.ENDPOINT_ADDRESS);
EndpointReferenceType reference = conduit != null ? conduit.getTarget() : ContextUtils.getNoneEndpointReference();
if (conduit != null && !StringUtils.isEmpty(s) && !reference.getAddress().getValue().equals(s)) {
EndpointReferenceType ref = new EndpointReferenceType();
AttributedURIType tp = new AttributedURIType();
tp.setValue(s);
ref.setAddress(tp);
ref.setMetadata(reference.getMetadata());
ref.setReferenceParameters(reference.getReferenceParameters());
ref.getOtherAttributes().putAll(reference.getOtherAttributes());
reference = ref;
}
maps.setTo(reference);
}
// ReplyTo, set if null in MAPs or if set to a generic address
// (anonymous or none) that may not be appropriate for the
// current invocation
EndpointReferenceType replyTo = maps.getReplyTo();
if (ContextUtils.isGenericAddress(replyTo)) {
replyTo = getReplyTo(message, replyTo);
if (replyTo == null || (isOneway && (replyTo == null || replyTo.getAddress() == null || !Names.WSA_NONE_ADDRESS.equals(replyTo.getAddress().getValue())))) {
AttributedURIType address = ContextUtils.getAttributedURI(isOneway ? Names.WSA_NONE_ADDRESS : Names.WSA_ANONYMOUS_ADDRESS);
replyTo = ContextUtils.WSA_OBJECT_FACTORY.createEndpointReferenceType();
replyTo.setAddress(address);
}
maps.setReplyTo(replyTo);
}
// FaultTo
if (maps.getFaultTo() == null) {
maps.setFaultTo(maps.getReplyTo());
} else if (maps.getFaultTo().getAddress() == null) {
maps.setFaultTo(null);
}
} else {
// add response-specific MAPs
AddressingProperties inMAPs = getMAPs(message, false, false);
maps.exposeAs(inMAPs.getNamespaceURI());
// on the fault status of the response)
if (isFault && inMAPs.getFaultTo() != null) {
maps.setTo(inMAPs.getFaultTo());
} else if (maps.getTo() == null && inMAPs.getReplyTo() != null) {
maps.setTo(inMAPs.getReplyTo());
}
// RelatesTo taken from MessageID in incoming MAPs
if (inMAPs.getMessageID() != null && !Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE))) {
String inMessageID = inMAPs.getMessageID().getValue();
maps.setRelatesTo(ContextUtils.getRelatesTo(inMessageID));
} else {
maps.setRelatesTo(ContextUtils.getRelatesTo(Names.WSA_UNSPECIFIED_RELATIONSHIP));
}
// fallback fault action
if (isFault && maps.getAction() == null) {
maps.setAction(ContextUtils.getAttributedURI(Names.WSA_DEFAULT_FAULT_ACTION));
}
if (isFault && !ContextUtils.isGenericAddress(inMAPs.getFaultTo())) {
Message m = message.getExchange().getInFaultMessage();
if (m == null) {
m = message;
}
InternalContextUtils.rebaseResponse(inMAPs.getFaultTo(), inMAPs, m);
Destination destination = InternalContextUtils.createDecoupledDestination(m.getExchange(), inMAPs.getFaultTo());
m.getExchange().setDestination(destination);
}
}
}
use of org.apache.cxf.transport.Destination in project cxf by apache.
the class DecoupledFaultHandler method handleFault.
// Ideally, this code will instead be executed as part of the Fault chain
// but at the moment PhaseInterceptorChain needs to be tricked that this is
// a two way request for a fault chain be invoked
public void handleFault(SoapMessage message) {
if (!ContextUtils.isRequestor(message)) {
Exchange exchange = message.getExchange();
Message inMessage = exchange.getInMessage();
final AddressingProperties maps = ContextUtils.retrieveMAPs(inMessage, false, false, true);
if (maps != null && !ContextUtils.isGenericAddress(maps.getFaultTo())) {
// Just keep the wsa headers to remove the not understand headers
if (exchange.getOutMessage() != null) {
message = (SoapMessage) exchange.getOutMessage();
}
Iterator<Header> iterator = message.getHeaders().iterator();
while (iterator.hasNext()) {
Header header = iterator.next();
if (!isWSAHeader(header)) {
iterator.remove();
}
}
exchange.setOneWay(false);
exchange.setOutMessage(message);
// manually set the action
message.put(ContextUtils.ACTION, WSA_ACTION);
Destination destination = createDecoupledDestination(exchange, maps.getFaultTo());
exchange.setDestination(destination);
}
}
}
use of org.apache.cxf.transport.Destination in project cxf by apache.
the class MAPAggregatorTest method setUpRebase.
private void setUpRebase(Message message, Exchange exchange, Endpoint endpoint) throws Exception {
setUpMessageProperty(message, "org.apache.cxf.ws.addressing.partial.response.sent", Boolean.FALSE);
Binding binding = control.createMock(Binding.class);
endpoint.getBinding();
EasyMock.expectLastCall().andReturn(binding).anyTimes();
Message partialResponse = getMessage();
binding.createMessage(EasyMock.isA(Message.class));
EasyMock.expectLastCall().andReturn(partialResponse);
Destination target = control.createMock(Destination.class);
setUpMessageDestination(message, target);
Conduit backChannel = control.createMock(Conduit.class);
target.getBackChannel(EasyMock.eq(message));
EasyMock.expectLastCall().andReturn(backChannel);
// REVISIT test interceptor chain setup & send
}
Aggregations