org.apache.cxf.endpoint.EndpointImpl Java Examples

The following examples show how to use org.apache.cxf.endpoint.EndpointImpl. 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: 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 #2
Source File: DocLiteralInInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void setUpUsingHelloWorld() throws Exception {
    String ns = "http://apache.org/hello_world_soap_http";
    WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass()
        .getResource("/wsdl/jaxb/hello_world.wsdl").toString(), new QName(ns, "SOAPService"));

    service = factory.create();
    endpointInfo = service.getEndpointInfo(new QName(ns, "SoapPort"));
    endpoint = new EndpointImpl(bus, service, endpointInfo);
    JAXBDataBinding db = new JAXBDataBinding();
    db.setContext(JAXBContext.newInstance(new Class[] {GreetMe.class, GreetMeResponse.class}));
    service.setDataBinding(db);

    operation = endpointInfo.getBinding().getOperation(new QName(ns, "greetMe"));
    operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(GreetMe.class);
    operation.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(GreetMeResponse.class);

    message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);

    exchange.put(Service.class, service);
    exchange.put(Endpoint.class, endpoint);
    exchange.put(Binding.class, endpoint.getBinding());
}
 
Example #3
Source File: DocLiteralInInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void setUpUsingDocLit() throws Exception {
    String ns = "http://apache.org/hello_world_doc_lit_bare";
    WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass()
        .getResource("/wsdl/jaxb/doc_lit_bare.wsdl").toString(), new QName(ns, "SOAPService"));

    service = factory.create();
    endpointInfo = service.getEndpointInfo(new QName(ns, "SoapPort"));
    endpoint = new EndpointImpl(bus, service, endpointInfo);
    JAXBDataBinding db = new JAXBDataBinding();
    db.setContext(JAXBContext.newInstance(new Class[] {TradePriceData.class}));
    service.setDataBinding(db);

    operation = endpointInfo.getBinding().getOperation(new QName(ns, "SayHi"));
    operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(TradePriceData.class);
    operation.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(TradePriceData.class);

    message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);

    exchange.put(Service.class, service);
    exchange.put(Endpoint.class, endpoint);
    exchange.put(Binding.class, endpoint.getBinding());
}
 
Example #4
Source File: BareInInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void setUpUsingHelloWorld() throws Exception {
    String ns = "http://apache.org/hello_world_soap_http";
    WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass()
        .getResource("/wsdl/jaxb/hello_world.wsdl").toString(),
                                                        new QName(ns, "SOAPService"));

    service = factory.create();
    endpointInfo = service.getServiceInfos().get(0).getEndpoint(new QName(ns, "SoapPort"));
    endpoint = new EndpointImpl(bus, service, endpointInfo);
    JAXBDataBinding db = new JAXBDataBinding();
    db.setContext(JAXBContext.newInstance(new Class[] {
        GreetMe.class,
        GreetMeResponse.class
    }));
    service.setDataBinding(db);

    operation = endpointInfo.getBinding().getOperation(new QName(ns, "greetMe"));
    operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(GreetMe.class);
    operation.getOperationInfo().getOutput()
        .getMessagePartByIndex(0).setTypeClass(GreetMeResponse.class);

    message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);

    exchange.put(Service.class, service);
    exchange.put(Endpoint.class, endpoint);
    exchange.put(Binding.class, endpoint.getBinding());
}
 
Example #5
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 #6
Source File: WadlGeneratorJsonTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Message mockMessage(String baseAddress, String pathInfo, String query,
                            ClassResourceInfo cri) throws Exception {
    Message m = new MessageImpl();
    Exchange e = new ExchangeImpl();
    e.put(Service.class, new JAXRSServiceImpl(Collections.singletonList(cri)));
    m.setExchange(e);
    control.reset();
    ServletDestination d = control.createMock(ServletDestination.class);
    EndpointInfo epr = new EndpointInfo();
    epr.setAddress(baseAddress);
    d.getEndpointInfo();
    EasyMock.expectLastCall().andReturn(epr).anyTimes();

    Endpoint endpoint = new EndpointImpl(null, null, epr);
    e.put(Endpoint.class, endpoint);

    e.setDestination(d);
    BindingInfo bi = control.createMock(BindingInfo.class);
    epr.setBinding(bi);
    bi.getProperties();
    EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes();
    m.put(Message.REQUEST_URI, pathInfo);
    m.put(Message.QUERY_STRING, query);
    m.put(Message.HTTP_REQUEST_METHOD, "GET");
    control.replay();
    return m;
}
 
Example #7
Source File: WadlGeneratorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Message mockMessage(String baseAddress, String pathInfo, String query,
                            List<ClassResourceInfo> cris) throws Exception {
    Message m = new MessageImpl();
    Exchange e = new ExchangeImpl();
    e.put(Service.class, new JAXRSServiceImpl(cris));
    m.setExchange(e);
    control.reset();
    ServletDestination d = control.createMock(ServletDestination.class);
    EndpointInfo epr = new EndpointInfo();
    epr.setAddress(baseAddress);
    d.getEndpointInfo();
    EasyMock.expectLastCall().andReturn(epr).anyTimes();

    Endpoint endpoint = new EndpointImpl(null, null, epr);
    e.put(Endpoint.class, endpoint);
    endpoint.put(ServerProviderFactory.class.getName(), ServerProviderFactory.getInstance());
    e.setDestination(d);
    BindingInfo bi = control.createMock(BindingInfo.class);
    epr.setBinding(bi);
    bi.getProperties();
    EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes();
    m.put(Message.REQUEST_URI, pathInfo);
    m.put(Message.QUERY_STRING, query);
    m.put(Message.HTTP_REQUEST_METHOD, "GET");
    control.replay();
    return m;
}
 
Example #8
Source File: GenericAegisTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testGenerateJavascript() throws Exception {
 // Create our service implementation
    GenericGenericClass<String> impl = new GenericGenericClass<>();

    // Create our Server
    ServerFactoryBean svrFactory = new ServerFactoryBean();
    // we sure can't get a .class for the interface, can we?
    svrFactory.setServiceClass(impl.getClass());
    svrFactory.setAddress("http://localhost:" + PORT + "/aegisgeneric");
    svrFactory.setServiceBean(impl);
    Server server = svrFactory.create();
    ServiceInfo serviceInfo = ((EndpointImpl)server.getEndpoint()).getEndpointInfo().getService();
    Collection<SchemaInfo> schemata = serviceInfo.getSchemas();
    BasicNameManager nameManager = BasicNameManager.newNameManager(serviceInfo);
    NamespacePrefixAccumulator prefixManager = new NamespacePrefixAccumulator(serviceInfo
        .getXmlSchemaCollection());
    for (SchemaInfo schema : schemata) {
        SchemaJavascriptBuilder builder = new SchemaJavascriptBuilder(serviceInfo
            .getXmlSchemaCollection(), prefixManager, nameManager);
        String allThatJavascript = builder.generateCodeForSchema(schema.getSchema());
        assertNotNull(allThatJavascript);
    }

    ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo, null,
                                                                           prefixManager, nameManager);
    serviceBuilder.walk();
    String serviceJavascript = serviceBuilder.getCode();
    assertNotNull(serviceJavascript);

}
 
Example #9
Source File: TestBase.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void common(String wsdl, QName portName, Class<?>... jaxbClasses) throws Exception {
    Bus bus = BusFactory.getDefaultBus();

    WSDLManagerImpl manager = new WSDLManagerImpl();
    XMLWSDLExtensionLoader.registerExtensors(manager);

    assertNotNull(bus.getExtension(WSDLManager.class));

    WSDLServiceFactory factory =
        new WSDLServiceFactory(bus, getClass().getResource(wsdl).toString(),
                               new QName(portName.getNamespaceURI(), "XMLService"));

    org.apache.cxf.service.Service service = factory.create();

    EndpointInfo epi = service.getEndpointInfo(portName);
    assertNotNull(epi);
    serviceInfo = epi.getService();

    JAXBDataBinding db = new JAXBDataBinding();
    db.initialize(service);
    db.setContext(JAXBContext.newInstance(jaxbClasses));
    service.setDataBinding(db);

    Endpoint endpoint = new EndpointImpl(bus, service, epi);

    xmlMessage.getExchange().put(Endpoint.class, endpoint);
    xmlMessage.getExchange().put(org.apache.cxf.service.Service.class, service);
}
 
Example #10
Source File: ManagedRMManagerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Endpoint createTestEndpoint() throws Exception {
    ServiceInfo svci = new ServiceInfo();
    svci.setName(new QName(TEST_URI, "testService"));
    Service svc = new ServiceImpl(svci);
    SoapBindingInfo binding = new SoapBindingInfo(svci, WSDLConstants.NS_SOAP11);
    binding.setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress(TEST_URI);
    ei.setName(new QName(TEST_URI, "testPort"));
    ei.setBinding(binding);
    ei.setService(svci);
    return new EndpointImpl(bus, svc, ei);
}
 
Example #11
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 #12
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 #13
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 #14
Source File: BareInInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void setUpUsingDocLit() throws Exception {
    String ns = "http://apache.org/hello_world_doc_lit_bare";
    WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass()
        .getResource("/wsdl/jaxb/doc_lit_bare.wsdl").toString(),
                                                        new QName(ns, "SOAPService"));

    service = factory.create();
    endpointInfo = service.getServiceInfos().get(0).getEndpoint(new QName(ns, "SoapPort"));
    endpoint = new EndpointImpl(bus, service, endpointInfo);
    JAXBDataBinding db = new JAXBDataBinding();
    db.setContext(JAXBContext.newInstance(new Class[] {
        TradePriceData.class
    }));
    service.setDataBinding(db);

    operation = endpointInfo.getBinding().getOperation(new QName(ns, "SayHi"));
    operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(TradePriceData.class);
    operation.getOperationInfo().getOutput()
        .getMessagePartByIndex(0).setTypeClass(TradePriceData.class);

    message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);

    exchange.put(Service.class, service);
    exchange.put(Endpoint.class, endpoint);
    exchange.put(Binding.class, endpoint.getBinding());
}
 
Example #15
Source File: MAPAggregatorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetReplyToUsingBaseAddress() throws Exception {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);

    final String localReplyTo = "/SoapContext/decoupled";
    final String decoupledEndpointBase = "http://localhost:8181/cxf";
    final String replyTo = decoupledEndpointBase + localReplyTo;

    ServiceInfo s = new ServiceInfo();
    Service svc = new ServiceImpl(s);
    EndpointInfo ei = new EndpointInfo();
    InterfaceInfo ii = s.createInterface(new QName("FooInterface"));
    s.setInterface(ii);
    ii.addOperation(new QName("fooOp"));
    SoapBindingInfo b = new SoapBindingInfo(s, "http://schemas.xmlsoap.org/soap/", Soap11.getInstance());
    b.setTransportURI("http://schemas.xmlsoap.org/soap/http");
    ei.setBinding(b);

    ei.setAddress("http://nowhere.com/bar/foo");
    ei.setName(new QName("http://nowhere.com/port", "foo"));
    Bus bus = new ExtensionManagerBus();
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    DestinationFactory df = control.createMock(DestinationFactory.class);
    Destination d = control.createMock(Destination.class);
    bus.setExtension(dfm, DestinationFactoryManager.class);
    EasyMock.expect(dfm.getDestinationFactoryForUri(localReplyTo)).andReturn(df);
    EasyMock.expect(df.getDestination(
        EasyMock.anyObject(EndpointInfo.class), EasyMock.anyObject(Bus.class))).andReturn(d);
    EasyMock.expect(d.getAddress()).andReturn(EndpointReferenceUtils.getEndpointReference(localReplyTo));

    Endpoint ep = new EndpointImpl(bus, svc, ei);
    exchange.put(Endpoint.class, ep);
    exchange.put(Bus.class, bus);
    exchange.setOutMessage(message);
    setUpMessageProperty(message,
                         REQUESTOR_ROLE,
                         Boolean.TRUE);
    message.getContextualProperty(WSAContextUtils.REPLYTO_PROPERTY);
    message.put(WSAContextUtils.REPLYTO_PROPERTY, localReplyTo);
    message.put(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY, decoupledEndpointBase);

    AddressingProperties maps = new AddressingProperties();
    AttributedURIType id =
        ContextUtils.getAttributedURI("urn:uuid:12345");
    maps.setMessageID(id);
    maps.setAction(ContextUtils.getAttributedURI(""));
    setUpMessageProperty(message,
                         CLIENT_ADDRESSING_PROPERTIES,
                         maps);
    control.replay();
    aggregator.mediate(message, false);
    AddressingProperties props =
        (AddressingProperties)message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND);

    assertEquals(replyTo, props.getReplyTo().getAddress().getValue());
    control.verify();
}
 
Example #16
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);
}
 
Example #17
Source File: TestBase.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    bus = BusFactory.newInstance().createBus();

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

    IMocksControl control = createNiceControl();
    BindingFactory bf = control.createMock(BindingFactory.class);
    Binding binding = control.createMock(Binding.class);
    expect(bf.createBinding(null)).andStubReturn(binding);
    expect(binding.getInFaultInterceptors())
        .andStubReturn(new ArrayList<Interceptor<? extends Message>>());
    expect(binding.getOutFaultInterceptors())
        .andStubReturn(new ArrayList<Interceptor<? extends Message>>());

    bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bf);

    String ns = "http://apache.org/hello_world_soap_http";
    WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass()
        .getResource("/org/apache/cxf/jaxb/resources/wsdl/hello_world.wsdl").toString(),
                                                        new QName(ns, "SOAPService"));

    service = factory.create();
    endpointInfo = service.getEndpointInfo(new QName(ns, "SoapPort"));
    endpoint = new EndpointImpl(bus, service, endpointInfo);
    JAXBDataBinding db = new JAXBDataBinding();
    db.setContext(JAXBContext.newInstance(new Class[] {
        GreetMe.class,
        GreetMeResponse.class
    }));
    service.setDataBinding(db);

    operation = endpointInfo.getBinding().getOperation(new QName(ns, "greetMe"));
    operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(GreetMe.class);
    operation.getOperationInfo().getOutput()
        .getMessagePartByIndex(0).setTypeClass(GreetMeResponse.class);

    message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);

    exchange.put(Service.class, service);
    exchange.put(Endpoint.class, endpoint);
    exchange.put(Binding.class, endpoint.getBinding());
}
 
Example #18
Source File: ReflectionServiceFactoryBean.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Endpoint createEndpoint(EndpointInfo ei) throws EndpointException {
    Endpoint ep = new EndpointImpl(getBus(), getService(), ei);
    sendEvent(Event.ENDPOINT_CREATED, ei, ep, getServiceClass());
    return ep;
}