Search in sources :

Example 1 with W3CEndpointReference

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()));
}
Also used : W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) EndpointTransformerImpl(org.talend.esb.servicelocator.client.internal.EndpointTransformerImpl) DOMResult(javax.xml.transform.dom.DOMResult) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) ArrayList(java.util.ArrayList) SLPropertiesImpl(org.talend.esb.servicelocator.client.SLPropertiesImpl) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 2 with W3CEndpointReference

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()));
}
Also used : W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Test(org.junit.Test)

Example 3 with W3CEndpointReference

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()));
}
Also used : W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Test(org.junit.Test)

Example 4 with W3CEndpointReference

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());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference)

Example 5 with W3CEndpointReference

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);
    }
}
Also used : ProtocolException(javax.xml.ws.ProtocolException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SOAPFactory(javax.xml.soap.SOAPFactory) RegisterResponseType(org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType) Registrar(com.arjuna.wsc11.Registrar) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) SOAPException(javax.xml.soap.SOAPException) RegistrarMapper(com.arjuna.wsc11.RegistrarMapper) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SOAPFault(javax.xml.soap.SOAPFault)

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