use of org.jboss.ws.api.addressing.MAPBuilder in project jbossws-cxf by jbossws.
the class ServerHandler method handleOutbound.
@Override
public boolean handleOutbound(SOAPMessageContext msgContext) {
log.info("handleResponse");
MAPBuilder builder = MAPBuilderFactory.getInstance().getBuilderInstance();
MAP inProps = builder.inboundMap(msgContext);
MAP outProps = builder.newMap();
outProps.initializeAsDestination(inProps.getReplyTo());
outProps.installOutboundMapOnServerSide(msgContext, outProps);
msgContext.setScope(builder.newConstants().getServerAddressingPropertiesOutbound(), Scope.APPLICATION);
return true;
}
use of org.jboss.ws.api.addressing.MAPBuilder in project jbossws-cxf by jbossws.
the class ServerHandler method handleInbound.
@Override
public boolean handleInbound(SOAPMessageContext msgContext) {
log.info("handleRequest");
MAPBuilder builder = MAPBuilderFactory.getInstance().getBuilderInstance();
MAP addrProps = builder.inboundMap(msgContext);
if (addrProps == null)
throw new IllegalStateException("Cannot obtain AddressingProperties");
String clientid = null;
MAPEndpoint replyTo = addrProps.getReplyTo();
for (Object obj : replyTo.getReferenceParameters()) {
if (obj instanceof Element) {
Element el = (Element) obj;
QName qname = getElementQName(el);
if (qname.equals(IDQN)) {
clientid = getTextContent(el);
}
} else {
log.warn("Unsupported reference parameter found: " + obj);
}
}
if (clientid == null)
throw new IllegalStateException("Cannot obtain client id");
// put the clientid in the message context
msgContext.put("clientid", clientid);
msgContext.setScope("clientid", Scope.APPLICATION);
return true;
}
use of org.jboss.ws.api.addressing.MAPBuilder in project jbossws-cxf by jbossws.
the class CXFMAP method getRelatesTo.
public MAPRelatesTo getRelatesTo() {
MAPBuilder builder = CXFMAPBuilder.getBuilder();
RelatesToType relatesTo = implementation.getRelatesTo();
if (relatesTo != null) {
String type = relatesTo.getRelationshipType();
QName relatesToType;
int index = type.indexOf("}");
if (index == -1) {
relatesToType = new QName(type);
} else {
String ns = type.substring(1, index + 1);
String name = type.substring(index + 1);
relatesToType = new QName(ns, name);
}
return builder.newRelatesTo(relatesTo.getValue(), relatesToType);
} else {
return null;
}
}
use of org.jboss.ws.api.addressing.MAPBuilder in project jbossws-cxf by jbossws.
the class AddressingPort method readClientID.
/**
* This verifies the client ID is available in inbound messages
*/
@SuppressWarnings("unchecked")
private void readClientID() {
BindingProvider bindingProvider = (BindingProvider) port;
Map<String, Object> msgContext = bindingProvider.getResponseContext();
MAPBuilder builder = MAPBuilderFactory.getInstance().getBuilderInstance();
MAP addrProps = builder.inboundMap(msgContext);
if (addrProps == null)
throw new IllegalStateException("Cannot obtain AddressingProperties");
for (Object obj : addrProps.getReferenceParameters()) {
if (// Native always uses Element for ref params
obj instanceof Element) {
Element el = (Element) obj;
QName qname = DOMUtils.getElementQName(el);
if (qname.equals(IDQN)) {
clientID = DOMUtils.getTextContent(el);
}
} else if (// CXF also uses JAXBElement
obj instanceof JAXBElement) {
JAXBElement<String> el = (JAXBElement<String>) obj;
if (IDQN.equals(el.getName())) {
clientID = el.getValue();
}
}
}
if (clientID == null)
throw new IllegalStateException("Cannot obtain clientid");
}
use of org.jboss.ws.api.addressing.MAPBuilder in project jbossws-cxf by jbossws.
the class AddressingPort method setClientID.
/**
* This installs the ID for this client in the outbound messages
*/
private void setClientID() {
BindingProvider bindingProvider = (BindingProvider) port;
Map<String, Object> msgContext = bindingProvider.getRequestContext();
MAPBuilder builder = MAPBuilderFactory.getInstance().getBuilderInstance();
MAPConstants ADDR = builder.newConstants();
MAP outProps = builder.newMap();
MAPEndpoint replyTo = builder.newEndpoint(ADDR.getAnonymousURI());
outProps.setReplyTo(replyTo);
outProps.setMessageID("urn:uuid:" + UUIDGenerator.generateRandomUUIDString());
// Assign a new clientid
if (clientID == null) {
clientID = "clientid-" + (++maxClientId);
log.info("New clientid: " + clientID);
}
try {
replyTo.addReferenceParameter(DOMUtils.parse(getClientIdElement(clientID), getDocumentBuilder()));
} catch (IOException e) {
throw new RuntimeException(e);
}
outProps.installOutboundMapOnClientSide(msgContext, outProps);
}
Aggregations