use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class ParticipantPortTypeImpl method fail.
/**
*/
@WebMethod(operationName = "Fail", action = "http://fabrikam123.com/wsba/Fail")
@Oneway
@Action(input = "http://fabrikam123.com/wsba/Fail")
@RequestWrapper(localName = "Fail", targetNamespace = "http://fabrikam123.com/wsba", className = "com.jboss.transaction.txinterop.webservices.bainterop.generated.TestMessageType")
public void fail() {
MessageContext ctx = webServiceCtx.getMessageContext();
MAP inboundMap = AddressingHelper.inboundMap(ctx);
CoordinationContextType coordinationContext = CoordinationContextManager.getContext(ctx);
try {
BAParticipantProcessor.getParticipant().fail(coordinationContext, inboundMap);
} catch (SoapFault11 sf) {
sendSoapFault(inboundMap, sf);
return;
}
sendResponse(inboundMap);
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class ParticipantPortTypeImpl method mixedOutcome.
/**
*/
@WebMethod(operationName = "MixedOutcome", action = "http://fabrikam123.com/wsba/MixedOutcome")
@Oneway
@Action(input = "http://fabrikam123.com/wsba/MixedOutcome")
@RequestWrapper(localName = "MixedOutcome", targetNamespace = "http://fabrikam123.com/wsba", className = "com.jboss.transaction.txinterop.webservices.bainterop.generated.TestMessageType")
public void mixedOutcome() {
MessageContext ctx = webServiceCtx.getMessageContext();
MAP inboundMap = AddressingHelper.inboundMap(ctx);
CoordinationContextType coordinationContext = CoordinationContextManager.getContext(ctx);
try {
BAParticipantProcessor.getParticipant().mixedOutcome(coordinationContext, inboundMap);
} catch (SoapFault11 sf) {
sendSoapFault(inboundMap, sf);
return;
}
sendResponse(inboundMap);
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class CoordinationContextHandler method handleMessageOutbound.
/**
* check for an arjuna context attached to the message context and, if found, install its identifier as the value
* of a soap message header element
* @param context
* @return
* @throws ProtocolException
*/
protected boolean handleMessageOutbound(SOAPMessageContext context) throws ProtocolException {
try {
CoordinationContextType coordinationContext = CoordinationContextManager.getThreadContext();
if (coordinationContext != null) {
final JAXBContext jaxbCtx = getJaxbContext();
// insert a header into the current message containing the coordination context
final SOAPMessage soapMessage = context.getMessage();
final SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = soapEnvelope.getHeader();
if (soapHeader == null) {
soapHeader = soapEnvelope.addHeader();
}
/*
* this does not work but it is what we want!!
*
* The problem here is that the marshaller creates plain old elements and inserts them top
* down as it goes along. but the soap header add child method checks its argument and
* replaces plain elements with soap header elements before inserting them. it copies the
* inserted element substructure into the rpelacement but since it does not exist at
* copy time the chiuldren get lost
Marshaller marshaller = jaxbCtx.createMarshaller();
marshaller.marshal(coordinationContext, soapHeader);
*/
/*
* ok, here's the workaround -- marshall the object as a child of a dummy header, detach it and
* then insert it as a header element.
*/
SOAPHeaderElement headerElement = soapHeader.addHeaderElement(getDummyQName());
Marshaller marshaller = jaxbCtx.createMarshaller();
marshaller.marshal(coordinationContext, headerElement);
soapHeader.replaceChild(headerElement.getChildNodes().item(0), headerElement);
// ok, now we need to locate the inserted node and set the mustunderstand attribute
Iterator<SOAPHeaderElement> iterator = soapHeader.examineAllHeaderElements();
while (iterator.hasNext()) {
headerElement = iterator.next();
if (CoordinationConstants.WSCOOR_ELEMENT_COORDINATION_CONTEXT_QNAME.equals(headerElement.getElementQName())) {
headerElement.setMustUnderstand(true);
break;
}
}
}
} catch (Exception se) {
throw new ProtocolException(se);
}
return true;
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class CoordinationContextHandler method handlemessageInbound.
/**
* check for an arjuna instance identifier element embedded in the soap message headesr and, if found, use it to
* label an arjuna context attached to the message context
* @param context
* @return
* @throws ProtocolException
*/
private boolean handlemessageInbound(SOAPMessageContext context) throws ProtocolException {
try {
final SOAPMessage soapMessage = context.getMessage();
final SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
Iterator<SOAPHeaderElement> iterator = soapEnvelope.getHeader().examineAllHeaderElements();
while (iterator.hasNext()) {
final SOAPHeaderElement headerElement = iterator.next();
if (CoordinationConstants.WSCOOR_ELEMENT_COORDINATION_CONTEXT_QNAME.equals(headerElement.getElementQName())) {
// found it - clear the must understand flag, retrieve the value and store an arjuna
// context in the message context
headerElement.setMustUnderstand(false);
final JAXBContext jaxbCtx = getJaxbContext();
final JAXBElement<CoordinationContextType> elt = jaxbCtx.createUnmarshaller().unmarshal(headerElement, CoordinationContextType.class);
final CoordinationContextType coordinationContext = elt.getValue();
CoordinationContextManager.setContext(context, coordinationContext);
}
}
} catch (Exception se) {
throw new ProtocolException(se);
}
return true;
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class RegistrationServiceExceptionTest method sendRegistration.
private W3CEndpointReference sendRegistration(String messageId, String protocolIdentifier) throws CannotRegisterException, InvalidStateException, InvalidProtocolException, SoapFault {
final CoordinationContextType coordinationContext = new CoordinationContextType();
CoordinationContextType.Identifier identifierInstance = new CoordinationContextType.Identifier();
coordinationContext.setCoordinationType(TestUtil.COORDINATION_TYPE);
coordinationContext.setIdentifier(identifierInstance);
identifierInstance.setValue("identifier");
coordinationContext.setRegistrationService(TestUtil11.getRegistrationEndpoint(identifierInstance.getValue()));
W3CEndpointReference participantEndpoint = TestUtil11.getProtocolParticipantEndpoint("participant");
return RegistrationCoordinator.register(coordinationContext, messageId, participantEndpoint, protocolIdentifier);
}
Aggregations