Search in sources :

Example 76 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project cxf by apache.

the class ManualHttpMulitplexClientServerTest method testWithManualMultiplexEprCreation.

@Test
public void testWithManualMultiplexEprCreation() throws Exception {
    NumberFactoryService service = new NumberFactoryService();
    NumberFactory nfact = service.getNumberFactoryPort();
    updateAddressPort(nfact, PORT);
    W3CEndpointReference w3cEpr = nfact.create("2");
    assertNotNull("reference", w3cEpr);
    // use the epr info only
    // no wsdl so default generated soap/http binding will be used
    // address url must come from the calling context
    EndpointReferenceType epr = ProviderImpl.convertToInternal(w3cEpr);
    QName serviceName = EndpointReferenceUtils.getServiceName(epr, bus);
    Service numService = Service.create(serviceName);
    String portString = EndpointReferenceUtils.getPortName(epr);
    QName portName = new QName(serviceName.getNamespaceURI(), portString);
    numService.addPort(portName, SoapBindingFactory.SOAP_11_BINDING, "http://foo");
    Number num = numService.getPort(portName, Number.class);
    setupContextWithEprAddress(epr, num);
    IsEvenResponse numResp = num.isEven();
    assertTrue("2 is even", numResp.isEven());
    // try again with the address from another epr
    w3cEpr = nfact.create("3");
    epr = ProviderImpl.convertToInternal(w3cEpr);
    setupContextWithEprAddress(epr, num);
    numResp = num.isEven();
    assertFalse("3 is not even", numResp.isEven());
    // try again with the address from another epr
    w3cEpr = nfact.create("6");
    epr = ProviderImpl.convertToInternal(w3cEpr);
    setupContextWithEprAddress(epr, num);
    numResp = num.isEven();
    assertTrue("6 is even", numResp.isEven());
}
Also used : NumberFactory(org.apache.cxf.factory_pattern.NumberFactory) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Number(org.apache.cxf.factory_pattern.Number) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) NumberFactoryService(org.apache.cxf.factory_pattern.NumberFactoryService) NumberService(org.apache.cxf.factory_pattern.NumberService) NumberFactoryService(org.apache.cxf.factory_pattern.NumberFactoryService) IsEvenResponse(org.apache.cxf.factory_pattern.IsEvenResponse) Test(org.junit.Test)

Example 77 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.

the class RegistrationCoordinator method register.

/**
 * Register the participant in the protocol.
 * @param coordinationContext The current coordination context
 * @param messageID The messageID to use.
 * @param participantProtocolService The participant protocol service.
 * @param protocolIdentifier The protocol identifier.
 * @return The endpoint reference of the coordinator protocol service.
 * @throws com.arjuna.wsc.InvalidProtocolException If the protocol is unsupported.
 * @throws com.arjuna.wsc.InvalidStateException If the state is invalid
 * @throws com.arjuna.webservices.SoapFault for errors during processing.
 */
public static W3CEndpointReference register(final CoordinationContextType coordinationContext, final String messageID, final W3CEndpointReference participantProtocolService, final String protocolIdentifier) throws CannotRegisterException, InvalidProtocolException, InvalidStateException, SoapFault {
    final W3CEndpointReference endpointReference = coordinationContext.getRegistrationService();
    try {
        final RegisterType registerType = new RegisterType();
        registerType.setProtocolIdentifier(protocolIdentifier);
        registerType.setParticipantProtocolService(participantProtocolService);
        final RegistrationPortType port = WSCOORClient.getRegistrationPort(endpointReference, CoordinationConstants.WSCOOR_ACTION_REGISTER, messageID);
        final RegisterResponseType response = registerOperation(messageID, port, registerType);
        return response.getCoordinatorProtocolService();
    } catch (SOAPFaultException sfe) {
        final SOAPFault soapFault = sfe.getFault();
        final Detail detail = soapFault.getDetail();
        String message = (detail != null ? detail.getTextContent() : soapFault.getFaultString());
        throwException(soapFault.getFaultCodeAsQName(), message, sfe, null);
        // impossible reach here
        return null;
    }
}
Also used : RegisterResponseType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SOAPFault(javax.xml.soap.SOAPFault) RegisterType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType) RegistrationPortType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegistrationPortType) Detail(javax.xml.soap.Detail)

Example 78 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.

the class TerminationCoordinatorProcessorImpl method close.

/**
 * Close.
 * @param close The close notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public void close(final NotificationType close, final MAP map, final ArjunaContext arjunaContext) {
    final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
    final BusinessActivityTerminator participant = getParticipant(instanceIdentifier);
    try {
        if (participant != null) {
            W3CEndpointReference endpoint = participant.getEndpoint();
            final String messageId = MessageId.getMessageId();
            try {
                participant.close();
            } catch (final UnknownTransactionException ute) {
                final MAP faultMAP = AddressingHelper.createFaultContext(map, messageId);
                final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_6());
                TerminationParticipantClient.getClient().sendSoapFault(endpoint, faultMAP, soapFault, instanceIdentifier);
                return;
            } catch (final TransactionRolledBackException trbe) {
                final MAP faultMAP = AddressingHelper.createFaultContext(map, messageId);
                final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.TRANSACTIONROLLEDBACK_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_7());
                TerminationParticipantClient.getClient().sendSoapFault(endpoint, faultMAP, soapFault, instanceIdentifier);
                return;
            } catch (final SystemException se) {
                final MAP faultMAP = AddressingHelper.createFaultContext(map, messageId);
                final String message = WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_8();
                final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME, message);
                TerminationParticipantClient.getClient().sendSoapFault(endpoint, faultMAP, soapFault, instanceIdentifier);
                return;
            } catch (final Throwable th) {
                if (WSTLogger.logger.isTraceEnabled()) {
                    WSTLogger.logger.tracev("Unexpected exception thrown from close:", th);
                }
                final MAP faultMAP = AddressingHelper.createFaultContext(map, MessageId.getMessageId());
                final SoapFault soapFault = new SoapFault11(th);
                TerminationParticipantClient.getClient().sendSoapFault(endpoint, faultMAP, soapFault, instanceIdentifier);
                return;
            }
            final MAP responseMAP = AddressingHelper.createNotificationContext(messageId);
            TerminationParticipantClient.getClient().sendClosed(endpoint, responseMAP, instanceIdentifier);
        } else {
            if (WSTLogger.logger.isTraceEnabled()) {
                WSTLogger.logger.tracev("Close called on unknown participant: {0}", new Object[] { instanceIdentifier });
            }
            final MAP faultMAP = AddressingHelper.createFaultContext(map, MessageId.getMessageId());
            final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_11());
            TerminationParticipantClient.getClient().sendSoapFault(soapFault, faultMAP, instanceIdentifier);
        }
    } catch (Throwable throwable) {
        throwable.printStackTrace(System.err);
    }
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) BusinessActivityTerminator(com.arjuna.wst11.BusinessActivityTerminator) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SoapFault11(com.arjuna.webservices11.SoapFault11) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) MAP(org.jboss.ws.api.addressing.MAP)

Example 79 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.

the class BusinessAgreementWithParticipantCompletionStub method restoreState.

public boolean restoreState(final InputObjectState ios) {
    try {
        final String id = ios.unpackString();
        final String eprValue = ios.unpackString();
        // this should successfully reverse the save process
        final XMLStreamReader reader = SoapUtils.getXMLStreamReader(new StringReader(eprValue));
        StreamHelper.checkNextStartTag(reader, QNAME_BAPCWS_PARTICIPANT);
        String eprefText = reader.getElementText();
        StreamSource source = new StreamSource(new StringReader(eprefText));
        final W3CEndpointReference endpointReference = new W3CEndpointReference(source);
        String ns = ios.unpackString();
        final String localPart = ios.unpackString();
        String prefix = ios.unpackString();
        if ("".equals(ns)) {
            ns = null;
        }
        if ("".equals(prefix)) {
            prefix = null;
        }
        QName statename = new QName(ns, localPart, prefix);
        State state = State.toState11(statename);
        // if we already have an engine from a previous recovery scan or because
        // we had a heuristic outcome then reuse it with luck it will have been committed
        // or aborted between the last scan and this one
        // note that whatever happens it will not have been removed from the table
        // because it is marked as recovered
        participant = (ParticipantCompletionCoordinatorEngine) ParticipantCompletionCoordinatorProcessor.getProcessor().getCoordinator(id);
        if (participant == null) {
            participant = new ParticipantCompletionCoordinatorEngine(id, endpointReference, state, true);
        }
        return true;
    } catch (final Throwable th) {
        WSTLogger.i18NLogger.error_wst11_stub_BusinessAgreementWithParticipantCompletionStub_3(th);
        return false;
    }
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) QName(javax.xml.namespace.QName) State(com.arjuna.webservices11.wsba.State) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader) ParticipantCompletionCoordinatorEngine(com.arjuna.wst11.messaging.engines.ParticipantCompletionCoordinatorEngine)

Example 80 with W3CEndpointReference

use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.

the class ParticipantStub method restoreState.

public boolean restoreState(final InputObjectState ios) {
    State state;
    try {
        final String id = ios.unpackString();
        final boolean durable = ios.unpackBoolean();
        final int stateTag = ios.unpackInt();
        switch(stateTag) {
            case 0:
                state = State.STATE_ACTIVE;
                break;
            case 1:
                state = State.STATE_PREPARING;
                break;
            case 2:
                state = State.STATE_PREPARED_SUCCESS;
                break;
            case 3:
                state = State.STATE_ABORTING;
                break;
            default:
                state = State.STATE_COMMITTING;
                break;
        }
        final String eprValue = ios.unpackString();
        // this should successfully reverse the save process
        final XMLStreamReader reader = SoapUtils.getXMLStreamReader(new StringReader(eprValue));
        StreamHelper.checkNextStartTag(reader, QNAME_TWO_PC_PARTICIPANT);
        String eprefText = reader.getElementText();
        StreamSource source = new StreamSource(new StringReader(eprefText));
        final W3CEndpointReference endpointReference = new W3CEndpointReference(source);
        // if we already have a coordinator from a previous recovery scan or because
        // we had a heuristic outcoe then reuse it with luck it will have been committed
        // or aborted between the last scan and this one
        // note that whatever happens it will not have been removed from the table
        // because it is marked as recovered
        coordinator = (CoordinatorEngine) CoordinatorProcessorImpl.getProcessor().getCoordinator(id);
        if (coordinator == null) {
            // no entry found so recreate one with the saved state
            coordinator = new CoordinatorEngine(id, durable, endpointReference, true, state);
        }
        return true;
    } catch (final Throwable th) {
        WSTLogger.i18NLogger.error_wst11_stub_ParticipantStub_2(th);
        return false;
    }
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) CoordinatorEngine(com.arjuna.wst11.messaging.engines.CoordinatorEngine) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) State(com.arjuna.webservices11.wsat.State) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader)

Aggregations

W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)154 Test (org.junit.Test)80 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)56 MAP (org.jboss.ws.api.addressing.MAP)53 SystemException (com.arjuna.wst.SystemException)16 UnknownTransactionException (com.arjuna.wst.UnknownTransactionException)16 QName (javax.xml.namespace.QName)16 W3CEndpointReferenceBuilder (javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)16 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)15 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)14 WrongStateException (com.arjuna.wst.WrongStateException)12 TransactionRolledBackException (com.arjuna.wst.TransactionRolledBackException)11 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)9 CoordinationContext (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)9 TxContextImple (com.arjuna.mwlabs.wst11.ba.context.TxContextImple)8 State (com.arjuna.webservices11.wsba.State)8 InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)8 CoordinatorCompletionCoordinatorDetails (com.arjuna.wst.tests.arq.TestCoordinatorCompletionCoordinatorProcessor.CoordinatorCompletionCoordinatorDetails)8 ParticipantCompletionParticipantDetails (com.arjuna.wst.tests.arq.TestParticipantCompletionParticipantProcessor.ParticipantCompletionParticipantDetails)8 URL (java.net.URL)8