Java Code Examples for org.apache.cxf.service.model.ServiceInfo#setInterface()

The following examples show how to use org.apache.cxf.service.model.ServiceInfo#setInterface() . 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: JAXRSServiceImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
public List<ServiceInfo> getServiceInfos() {
    if (!createServiceModel) {
        return Collections.emptyList();
    }
    // try to convert to WSDL-centric model so that CXF DataBindings can get initialized
    // might become useful too if we support wsdl2

    // make databindings to use databinding-specific information
    // like @XmlRootElement for ex to select a namespace
    this.put("org.apache.cxf.databinding.namespace", "true");

    List<ServiceInfo> infos = new ArrayList<>();
    for (ClassResourceInfo cri : classResourceInfos) {
        ServiceInfo si = new ServiceInfo();
        infos.add(si);
        QName qname = JAXRSUtils.getClassQName(cri.getServiceClass());
        si.setName(qname);
        InterfaceInfo inf = new InterfaceInfo(si, qname);
        si.setInterface(inf);
        for (OperationResourceInfo ori : cri.getMethodDispatcher().getOperationResourceInfos()) {
            Method m = ori.getMethodToInvoke();
            QName oname = new QName(qname.getNamespaceURI(), m.getName());
            OperationInfo oi = inf.addOperation(oname);
            createMessagePartInfo(oi, m.getReturnType(), qname, m, false);
            for (Parameter pm : ori.getParameters()) {

                if (pm.getType() == ParameterType.REQUEST_BODY) {
                    createMessagePartInfo(oi,
                                          ori.getMethodToInvoke().getParameterTypes()[pm.getIndex()],
                                          qname, m, true);
                }
            }
        }

    }
    return infos;
}
 
Example 2
Source File: SoapActionInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private BindingOperationInfo createBindingOperation() {
    ServiceInfo s = new ServiceInfo();
    InterfaceInfo ii = s.createInterface(new QName("FooInterface"));
    s.setInterface(ii);
    ii.addOperation(new QName("fooOp"));

    BindingInfo b = new BindingInfo(s, "foo");
    return b.buildOperation(new QName("fooOp"), null, null);
}
 
Example 3
Source File: ServiceUtils.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
public static Service createServiceModel() {
    ServiceInfo serviceInfo = new ServiceInfo();
    // does not make sense for protobuf services
    serviceInfo.setName(new QName("", "protobuf_service_"
            + System.identityHashCode(serviceInfo)));

    InterfaceInfo interfaceInfo = new InterfaceInfo(serviceInfo,
            serviceInfo.getName());
    serviceInfo.setInterface(interfaceInfo);

    Service service = new ServiceImpl(serviceInfo);

    return service;
}
 
Example 4
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 5
Source File: ReflectionServiceFactoryBean.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected ServiceInfo createServiceInfo(InterfaceInfo intf) {
    ServiceInfo svcInfo = new ServiceInfo();
    svcInfo.setInterface(intf);

    return svcInfo;
}