Search in sources :

Example 31 with CoordinationContext

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);
}
Also used : SoapFault11(com.arjuna.webservices11.SoapFault11) MessageContext(javax.xml.ws.handler.MessageContext) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) MAP(org.jboss.ws.api.addressing.MAP) Action(javax.xml.ws.Action) RequestWrapper(javax.xml.ws.RequestWrapper)

Example 32 with CoordinationContext

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);
}
Also used : SoapFault11(com.arjuna.webservices11.SoapFault11) MessageContext(javax.xml.ws.handler.MessageContext) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) MAP(org.jboss.ws.api.addressing.MAP) Action(javax.xml.ws.Action) RequestWrapper(javax.xml.ws.RequestWrapper)

Example 33 with CoordinationContext

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;
}
Also used : SOAPHeaderElement(javax.xml.soap.SOAPHeaderElement) ProtocolException(javax.xml.ws.ProtocolException) Marshaller(javax.xml.bind.Marshaller) JAXBContext(javax.xml.bind.JAXBContext) SOAPEnvelope(javax.xml.soap.SOAPEnvelope) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) SOAPMessage(javax.xml.soap.SOAPMessage) SOAPHeader(javax.xml.soap.SOAPHeader) ProtocolException(javax.xml.ws.ProtocolException) JAXBException(javax.xml.bind.JAXBException)

Example 34 with CoordinationContext

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;
}
Also used : SOAPHeaderElement(javax.xml.soap.SOAPHeaderElement) ProtocolException(javax.xml.ws.ProtocolException) JAXBContext(javax.xml.bind.JAXBContext) SOAPEnvelope(javax.xml.soap.SOAPEnvelope) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) SOAPMessage(javax.xml.soap.SOAPMessage) ProtocolException(javax.xml.ws.ProtocolException) JAXBException(javax.xml.bind.JAXBException)

Example 35 with CoordinationContext

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);
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)

Aggregations

CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)69 MAP (org.jboss.ws.api.addressing.MAP)43 SoapFault11 (com.arjuna.webservices11.SoapFault11)39 Action (javax.xml.ws.Action)38 RequestWrapper (javax.xml.ws.RequestWrapper)38 MessageContext (javax.xml.ws.handler.MessageContext)38 CoordinationContext (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)24 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)14 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)12 CreateCoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType)9 Expires (org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires)9 Test (org.junit.Test)7 SoapFault (com.arjuna.webservices.SoapFault)6 InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)6 SystemException (com.arjuna.wst.SystemException)6 TxContextImple (com.arjuna.mwlabs.wst11.at.context.TxContextImple)5 ServiceRegistry (com.arjuna.webservices11.ServiceRegistry)5 SOAPEnvelope (javax.xml.soap.SOAPEnvelope)5 SOAPHeaderElement (javax.xml.soap.SOAPHeaderElement)5 ProtocolException (javax.xml.ws.ProtocolException)5