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());
}
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;
}
}
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);
}
}
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;
}
}
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;
}
}
Aggregations