use of javax.xml.ws.wsaddressing.W3CEndpointReference in project tesb-rt-se by Talend.
the class LocatorRestServiceTest method lookUpEndpointWithReturnProps.
@Test
public void lookUpEndpointWithReturnProps() throws ServiceLocatorException, InterruptedException {
names.clear();
names.add(ENDPOINTURL);
SLPropertiesImpl slPropertiesImpl = new SLPropertiesImpl();
List<String> list = new ArrayList<String>();
slPropertiesImpl.addProperty("test", list);
expect(sl.lookup(SERVICE_NAME)).andStubReturn(names);
expect(sl.getEndpoint(SERVICE_NAME, ENDPOINTURL)).andStubReturn(endpoint);
expect(endpoint.getProperties()).andStubReturn(slPropertiesImpl);
replayAll();
W3CEndpointReference endpointRef, expectedRef;
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
// builder.serviceName(SERVICE_NAME);
builder.address(ENDPOINTURL);
EndpointTransformerImpl transformer = new EndpointTransformerImpl();
DOMResult result = new DOMResult();
transformer.writePropertiesTo(slPropertiesImpl, result);
Document docResult = (Document) result.getNode();
builder.metadata(docResult.getDocumentElement());
expectedRef = builder.build();
endpointRef = lps.lookupEndpoint(SERVICE_NAME.toString(), new ArrayList<String>());
assertTrue(endpointRef.toString().equals(expectedRef.toString()));
}
use of javax.xml.ws.wsaddressing.W3CEndpointReference in project tesb-rt-se by Talend.
the class LocatorSoapServiceTest method lookUpEndpoints.
@Test
public void lookUpEndpoints() throws InterruptedExceptionFault, ServiceLocatorFault, ServiceLocatorException, InterruptedException {
names.clear();
names.add(ENDPOINTURL);
expect(sl.lookup(SERVICE_NAME)).andStubReturn(names);
expect(sl.getEndpoint(SERVICE_NAME, ENDPOINTURL)).andStubReturn(endpoint);
expect(endpoint.getProperties()).andStubReturn(SLPropertiesImpl.EMPTY_PROPERTIES);
replayAll();
W3CEndpointReference endpointRef, expectedRef;
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
// builder.serviceName(SERVICE_NAME);
builder.address(ENDPOINTURL);
expectedRef = builder.build();
List<W3CEndpointReference> refs;
refs = lps.lookupEndpoints(SERVICE_NAME, null);
endpointRef = refs.get(0);
assertTrue(endpointRef.toString().equals(expectedRef.toString()));
}
use of javax.xml.ws.wsaddressing.W3CEndpointReference in project tesb-rt-se by Talend.
the class LocatorSoapServiceTest method lookUpEndpoint.
@Test
public void lookUpEndpoint() throws InterruptedExceptionFault, ServiceLocatorFault, ServiceLocatorException, InterruptedException {
names.clear();
names.add(ENDPOINTURL);
expect(sl.lookup(SERVICE_NAME)).andStubReturn(names);
expect(sl.getEndpoint(SERVICE_NAME, ENDPOINTURL)).andStubReturn(endpoint);
expect(endpoint.getProperties()).andStubReturn(SLPropertiesImpl.EMPTY_PROPERTIES);
replayAll();
W3CEndpointReference endpointRef, expectedRef;
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
// builder.serviceName(SERVICE_NAME);
builder.address(ENDPOINTURL);
expectedRef = builder.build();
endpointRef = lps.lookupEndpoint(SERVICE_NAME, null);
assertTrue(endpointRef.toString().equals(expectedRef.toString()));
}
use of javax.xml.ws.wsaddressing.W3CEndpointReference in project tesb-rt-se by Talend.
the class RESTClient method lookupEndpointExample.
private void lookupEndpointExample(LocatorService client, String service) throws IOException {
System.out.println("------------------------------");
System.out.println("LookupEndpoint");
try {
W3CEndpointReference w3cEndpointReference = client.lookupEndpoint(URLEncoder.encode(service, "UTF-8"), null);
System.out.println(w3cEndpointReference.toString());
} catch (WebApplicationException ex) {
System.out.println(ex.getMessage());
}
}
use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.
the class RegistrationCoordinatorProcessorImpl method register.
/**
* Register the participant in the protocol.
* @param register The register request.
* @param map The addressing context.
* @param arjunaContext The arjuna context.
*/
public RegisterResponseType register(final RegisterType register, final MAP map, final ArjunaContext arjunaContext, final boolean isSecure) {
final com.arjuna.wsc11.RegistrarMapper registrarMapper = RegistrarMapper.getFactory();
try {
final String protocolIdentifier = register.getProtocolIdentifier();
final Registrar registrar = registrarMapper.getRegistrar(protocolIdentifier);
if (registrar != null) {
try {
final W3CEndpointReference participantProtocolService = register.getParticipantProtocolService();
final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
final W3CEndpointReference coordinationProtocolService = registrar.register(participantProtocolService, protocolIdentifier, instanceIdentifier, isSecure);
final RegisterResponseType response = new RegisterResponseType();
response.setCoordinatorProtocolService(coordinationProtocolService);
return response;
} catch (final AlreadyRegisteredException alreadyRegisteredException) {
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME);
soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME).addTextNode(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_1());
throw new SOAPFaultException(soapFault);
} catch (final InvalidProtocolException invalidProtocolException) {
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PROTOCOL_QNAME);
soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME).addTextNode(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_2());
throw new SOAPFaultException(soapFault);
} catch (final InvalidStateException InvalidStateException) {
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_STATE_QNAME);
soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_STATE_QNAME).addTextNode(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_3());
throw new SOAPFaultException(soapFault);
} catch (final NoActivityException noActivityException) {
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME);
soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME).addTextNode(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_4());
throw new SOAPFaultException(soapFault);
} catch (final Throwable th) {
if (WSCLogger.logger.isTraceEnabled()) {
WSCLogger.logger.tracev("Unexpected exception thrown from create:", th);
}
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME);
soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME).addTextNode(th.getMessage());
throw new SOAPFaultException(soapFault);
}
} else {
if (WSCLogger.logger.isTraceEnabled()) {
WSCLogger.logger.tracev("Register called for unknown protocol identifier: {0}", new Object[] { protocolIdentifier });
}
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PROTOCOL_QNAME);
soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME).addTextNode(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_2());
throw new SOAPFaultException(soapFault);
}
} catch (SOAPException se) {
se.printStackTrace(System.err);
throw new ProtocolException(se);
}
}
Aggregations