org.apache.cxf.endpoint.EndpointException Java Examples

The following examples show how to use org.apache.cxf.endpoint.EndpointException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClientFactoryBean.java    From cxf with Apache License 2.0 6 votes vote down vote up
public Client create() {
    getServiceFactory().reset();
    if (getServiceFactory().getProperties() == null) {
        getServiceFactory().setProperties(properties);
    } else if (properties != null) {
        getServiceFactory().getProperties().putAll(properties);
    }
    Client client = null;
    Endpoint ep = null;
    try {
        ep = createEndpoint();
        this.getServiceFactory().sendEvent(FactoryBeanListener.Event.PRE_CLIENT_CREATE, ep);
        applyProperties(ep);
        client = createClient(ep);
        initializeAnnotationInterceptors(ep, getServiceClass());
    } catch (EndpointException | BusException e) {
        throw new ServiceConstructionException(e);
    }
    applyFeatures(client);
    this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED, client, ep);
    return client;
}
 
Example #2
Source File: AbstractSTSTokenTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
static MessageImpl prepareMessage(Bus bus, STSClient stsClient, String serviceAddress) throws EndpointException {
    MessageImpl message = new MessageImpl();
    message.put(SecurityConstants.STS_CLIENT, stsClient);
    message.put(Message.ENDPOINT_ADDRESS, serviceAddress);

    Exchange exchange = new ExchangeImpl();
    ServiceInfo si = new ServiceInfo();
    si.setName(new QName("http://www.apache.org", "ServiceName"));
    Service s = new ServiceImpl(si);
    EndpointInfo ei = new EndpointInfo();
    ei.setName(new QName("http://www.apache.org", "EndpointName"));
    Endpoint ep = new EndpointImpl(bus, s, ei);
    ei.setBinding(new BindingInfo(si, null));
    message.setExchange(exchange);
    exchange.put(Endpoint.class, ep);
    return message;
}
 
Example #3
Source File: CxfRsHttpListener.java    From tomee with Apache License 2.0 5 votes vote down vote up
private JAXRSServerFactoryBean newFactory(final String prefix, final String service, final String endpoint) {
    final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean() {
        @Override
        protected Endpoint createEndpoint() throws BusException, EndpointException {
            final Endpoint created = super.createEndpoint();
            created.put(ManagedEndpoint.SERVICE_NAME, service);
            created.put(ManagedEndpoint.ENDPOINT_NAME, endpoint);
            return created;
        }
    };
    factory.setDestinationFactory(transportFactory);
    factory.setBus(CxfUtil.getBus());
    factory.setAddress(prefix);
    return factory;
}
 
Example #4
Source File: STSUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
public static Endpoint createSTSEndpoint(Bus bus, 
                                         String namespace,
                                         String transportId,
                                         String location,
                                         String soapVersion,
                                         Policy policy,
                                         QName epName) throws BusException, EndpointException {
    return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, epName, false);
}
 
Example #5
Source File: AbstractJAXRSFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Endpoint createEndpoint() throws BusException, EndpointException {
    Service service = serviceFactory.getService();

    if (service == null) {
        service = serviceFactory.create();
    }

    EndpointInfo ei = createEndpointInfo(service);
    Endpoint ep = new EndpointImpl(getBus(), service, ei);

    if (properties != null) {
        ep.putAll(properties);
    }

    if (getInInterceptors() != null) {
        ep.getInInterceptors().addAll(getInInterceptors());
    }
    if (getOutInterceptors() != null) {
        ep.getOutInterceptors().addAll(getOutInterceptors());
    }
    if (getInFaultInterceptors() != null) {
        ep.getInFaultInterceptors().addAll(getInFaultInterceptors());
    }
    if (getOutFaultInterceptors() != null) {
        ep.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
    }

    List<ClassResourceInfo> list = serviceFactory.getRealClassResourceInfo();
    for (ClassResourceInfo cri : list) {
        initializeAnnotationInterceptors(ep, cri.getServiceClass());
        serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINT_SELECTED, ei, ep,
                                 cri.getServiceClass(), null);
    }
    ep.put(JAXRSServiceFactoryBean.class.getName(), serviceFactory);
    return ep;
}
 
Example #6
Source File: STSUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static Endpoint createSTSEndpoint(Bus bus,
                                         String namespace,
                                         String transportId,
                                         String location,
                                         String soapVersion,
                                         Policy policy,
                                         QName epName) throws BusException, EndpointException {
    return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, epName, false);
}
 
Example #7
Source File: STSUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static Endpoint createSCEndpoint(Bus bus,
                                         String namespace,
                                         String transportId,
                                         String location,
                                         String soapVersion,
                                         Policy policy) throws BusException, EndpointException {
    return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, null, true);
}
 
Example #8
Source File: RMEndpointTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateEndpoint() throws NoSuchMethodException, EndpointException {
    Method m = RMEndpoint.class.getDeclaredMethod("getUsingAddressing", new Class[] {EndpointInfo.class});
    Service as = control.createMock(Service.class);
    EndpointInfo aei = new EndpointInfo();
    ae = new EndpointImpl(null, as, aei);
    rme = EasyMock.createMockBuilder(RMEndpoint.class).withConstructor(manager, ae)
        .addMockedMethod(m).createMock(control);
    rme.setAplicationEndpoint(ae);
    rme.setManager(manager);
    SoapBindingInfo bi = control.createMock(SoapBindingInfo.class);
    aei.setBinding(bi);
    SoapVersion sv = Soap11.getInstance();
    EasyMock.expect(bi.getSoapVersion()).andReturn(sv);
    String ns = "http://schemas.xmlsoap.org/wsdl/soap/";
    EasyMock.expect(bi.getBindingId()).andReturn(ns);
    aei.setTransportId(ns);
    String addr = "addr";
    aei.setAddress(addr);
    Object ua = new Object();
    EasyMock.expect(rme.getUsingAddressing(aei)).andReturn(ua);
    control.replay();
    rme.createServices();
    rme.createEndpoints(null);
    Endpoint e = rme.getEndpoint(ProtocolVariation.RM10WSA200408);
    WrappedEndpoint we = (WrappedEndpoint)e;
    assertSame(ae, we.getWrappedEndpoint());
    Service s = rme.getService(ProtocolVariation.RM10WSA200408);
    assertEquals(1, s.getEndpoints().size());
    assertSame(e, s.getEndpoints().get(RM10Constants.PORT_NAME));
}
 
Example #9
Source File: ReflectionServiceFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void createEndpoints() {
    Service service = getService();

    BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);

    for (ServiceInfo inf : service.getServiceInfos()) {
        for (EndpointInfo ei : inf.getEndpoints()) {

            for (BindingOperationInfo boi : ei.getBinding().getOperations()) {
                updateBindingOperation(boi);
            }
            try {
                bfm.getBindingFactory(ei.getBinding().getBindingId());
            } catch (BusException e1) {
                continue;
            }

            try {
                Endpoint ep = createEndpoint(ei);

                service.getEndpoints().put(ei.getName(), ep);
            } catch (EndpointException e) {
                throw new ServiceConstructionException(e);
            }
        }
    }
}
 
Example #10
Source File: ServiceModelUtilsTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Service getService(URL wsdl, Class<?> implClz, QName port) throws EndpointException {
    assertNotNull(wsdl);
    bean.setWsdlURL(wsdl.toString());
    bean.setServiceClass(implClz);
    Service service = bean.create();
    EndpointInfo endpointInfo = service.getServiceInfos().get(0).getEndpoint(port);
    Endpoint endpoint = new EndpointImpl(getBus(), service, endpointInfo);
    exchange.put(Service.class, service);
    exchange.put(Endpoint.class, endpoint);
    return service;
}
 
Example #11
Source File: ServiceUtils.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
public static Endpoint createEndpoint(Bus bus, String address,
                                      Service service) throws EndpointException {
    BindingInfo bindingInfo = createBindingInfo(bus, service,
            ProtobufBindingFactory.PROTOBUF_BINDING_ID);

    return createEndpoint(bus, address, service, bindingInfo);
}
 
Example #12
Source File: ServiceUtils.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
public static Endpoint createEndpoint(Bus bus, String address,
                                      Service service, BindingInfo bindingInfo) throws EndpointException {
    EndpointInfo endpointInfo = createEndpointInfo(bus, service
            .getServiceInfos().get(0), bindingInfo, address);
    EndpointImpl endpoint = new EndpointImpl(bus, service, endpointInfo);

    return endpoint;
}
 
Example #13
Source File: SimpleRpcChannel.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
/**
 * @param messageSender
 * @param wrapperMessage
 * @throws org.apache.cxf.endpoint.EndpointException
 */
public SimpleRpcChannel(String address, Class<? extends Message> wrapperMessage) throws EndpointException {
    this.messageSender = new ProtobufClient(address, wrapperMessage);
    this.wrapperMessage = wrapperMessage;

    initialize();
}
 
Example #14
Source File: ProtobufClient.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
/**
 * @param address
 * @param wrapperMessage
 * @throws org.apache.cxf.endpoint.EndpointException
 */
public ProtobufClient(String address, Class<? extends Message> messageClass)
        throws EndpointException {
    super();
    this.address = address;
    this.endpoint = ServiceUtils.createEndpoint(getBus(), address);
    endpoint.put(Message.class.getName(), messageClass);

    getOutInterceptors().add(new ProtobufMessageOutInterceptor());
    getInInterceptors().add(new ProtobufMessageInInterceptor());
}
 
Example #15
Source File: ProtobufferImporterTest.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
@Test
public void testDenyDeclaration() throws BinderException, InvalidSyntaxException, ClassNotFoundException, InterruptedException, InvocationTargetException, EndpointException, IllegalAccessException, NoSuchMethodException {
    ImportDeclaration declaration = getValidDeclarations().get(0);
    fuchsiaDeclarationBinder.useDeclaration(declaration);
    Map<String, Server> serverPublished = field("registeredImporter").ofType(Map.class).in(fuchsiaDeclarationBinder).get();
    Assert.assertEquals(1, serverPublished.size());
    fuchsiaDeclarationBinder.denyDeclaration(declaration);
    Assert.assertEquals(0, serverPublished.size());
}
 
Example #16
Source File: ProtobufferExporterTest.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
@Test
public void endpointStartupAndCleanup() throws BinderException, InvalidSyntaxException, ClassNotFoundException, InterruptedException, InvocationTargetException, EndpointException, IllegalAccessException, NoSuchMethodException {
    ExportDeclaration declaration = getValidDeclarations().get(0);
    fuchsiaDeclarationBinder.useDeclaration(declaration);
    Map<String, Server> serverPublished = field("serverPublished").ofType(Map.class).in(fuchsiaDeclarationBinder).get();
    Assert.assertEquals(1, serverPublished.size());
    fuchsiaDeclarationBinder.stop();
    Assert.assertEquals(0, serverPublished.size());
}
 
Example #17
Source File: ProtobufferExporterTest.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
@Test
public void testDenyDeclaration() throws BinderException, InvalidSyntaxException, ClassNotFoundException, InterruptedException, InvocationTargetException, EndpointException, IllegalAccessException, NoSuchMethodException {
    ExportDeclaration declaration = getValidDeclarations().get(0);
    fuchsiaDeclarationBinder.useDeclaration(declaration);
    Map<String, Server> serverPublished = field("serverPublished").ofType(Map.class).in(fuchsiaDeclarationBinder).get();
    Assert.assertEquals(1, serverPublished.size());
    fuchsiaDeclarationBinder.denyDeclaration(declaration);
    Assert.assertEquals(0, serverPublished.size());
}
 
Example #18
Source File: ProtobufferExporterTest.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
private AddressBookProtos.AddressBookService connectExportedProtobufAddress(ExportDeclaration declaration) throws EndpointException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, BinderException {
    ProtobufferExportDeclarationWrapper pojo = ProtobufferExportDeclarationWrapper.create(declaration);
    Bus cxfbus = BusFactory.getThreadDefaultBus();
    BindingFactoryManager mgr = cxfbus.getExtension(BindingFactoryManager.class);
    mgr.registerBindingFactory(ProtobufBindingFactory.PROTOBUF_BINDING_ID, new ProtobufBindingFactory(cxfbus));
    Class<?> bufferService = AddressBookProtos.AddressBookService.class;
    Class<?> bufferMessage = AddressBookProtos.AddressBookServiceMessage.class;
    Class<? extends Message> generic = bufferMessage.asSubclass(Message.class);
    RpcChannel channel = new SimpleRpcChannel(pojo.getAddress(), generic);
    Method method = bufferService.getMethod("newStub", RpcChannel.class);
    Object service = method.invoke(bufferService, channel);
    AddressBookProtos.AddressBookService addressBook = (AddressBookProtos.AddressBookService) service;
    return addressBook;
}
 
Example #19
Source File: STSUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
public static Endpoint createSCEndpoint(Bus bus, 
                                         String namespace,
                                         String transportId,
                                         String location,
                                         String soapVersion,
                                         Policy policy) throws BusException, EndpointException {
    return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, null, true);
}
 
Example #20
Source File: STSUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
public static Endpoint createSCEndpoint(Bus bus, 
                                         String namespace,
                                         String transportId,
                                         String location,
                                         String soapVersion,
                                         Policy policy) throws BusException, EndpointException {
    return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, null, true);
}
 
Example #21
Source File: STSUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
public static Endpoint createSTSEndpoint(Bus bus, 
                                         String namespace,
                                         String transportId,
                                         String location,
                                         String soapVersion,
                                         Policy policy,
                                         QName epName) throws BusException, EndpointException {
    return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, epName, false);
}
 
Example #22
Source File: STSUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
public static Endpoint createSCEndpoint(Bus bus, 
                                         String namespace,
                                         String transportId,
                                         String location,
                                         String soapVersion,
                                         Policy policy) throws BusException, EndpointException {
    return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, null, true);
}
 
Example #23
Source File: STSUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
public static Endpoint createSTSEndpoint(Bus bus, 
                                         String namespace,
                                         String transportId,
                                         String location,
                                         String soapVersion,
                                         Policy policy,
                                         QName epName) throws BusException, EndpointException {
    return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, epName, false);
}
 
Example #24
Source File: STSUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
public static Endpoint createSCEndpoint(Bus bus, 
                                         String namespace,
                                         String transportId,
                                         String location,
                                         String soapVersion,
                                         Policy policy) throws BusException, EndpointException {
    return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, null, true);
}
 
Example #25
Source File: STSUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
public static Endpoint createSTSEndpoint(Bus bus, 
                                         String namespace,
                                         String transportId,
                                         String location,
                                         String soapVersion,
                                         Policy policy,
                                         QName epName) throws BusException, EndpointException {
    return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, epName, false);
}
 
Example #26
Source File: JaxWsServiceFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
public Endpoint createEndpoint(EndpointInfo ei) throws EndpointException {
    Endpoint ep = new JaxWsEndpointImpl(getBus(), getService(), ei, implInfo, wsFeatures,
                                 this.getFeatures(), this.isFromWsdl());
    sendEvent(FactoryBeanListener.Event.ENDPOINT_CREATED, ei, ep);
    return ep;
}
 
Example #27
Source File: ServiceUtils.java    From fuchsia with Apache License 2.0 4 votes vote down vote up
public static Endpoint createEndpoint(Bus bus, String address)
        throws EndpointException {
    return createEndpoint(bus, address, createServiceModel());
}
 
Example #28
Source File: JaxWsClientEndpointImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public JaxWsClientEndpointImpl(Bus bus, Service s, EndpointInfo ei, ServiceImpl si,
                               List<WebServiceFeature> wf)
    throws EndpointException {
    super(bus, s, ei, wf);
    executorProvider = si;
}
 
Example #29
Source File: AbstractSTSClient.java    From steady with Apache License 2.0 4 votes vote down vote up
public Client getClient()  throws BusException, EndpointException {
    if (client == null) {
        createClient();
    }
    return client;
}
 
Example #30
Source File: JaxWsEndpointImplFactory.java    From cxf with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc}*/
public EndpointImpl newEndpointImpl(Bus bus, Service service, EndpointInfo endpointInfo)
    throws EndpointException {
    return new JaxWsEndpointImpl(bus, service, endpointInfo);
}