Search in sources :

Example 6 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class ReflectionServiceFactoryBean method createInterface.

protected InterfaceInfo createInterface(ServiceInfo serviceInfo) {
    QName intfName = getInterfaceName();
    InterfaceInfo intf = new InterfaceInfo(serviceInfo, intfName);
    Method[] methods = getServiceClass().getMethods();
    // The BP profile states we can't have operations of the same name
    // so we have to append numbers to the name. Different JVMs sort methods
    // differently.
    // We need to keep them ordered so if we have overloaded methods, the
    // wsdl is generated the same every time across JVMs and across
    // client/servers.
    Arrays.sort(methods, new MethodComparator());
    for (Method m : methods) {
        if (isValidMethod(m)) {
            createOperation(serviceInfo, intf, m);
        }
    }
    sendEvent(Event.INTERFACE_CREATED, intf, getServiceClass());
    return intf;
}
Also used : QName(javax.xml.namespace.QName) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Method(java.lang.reflect.Method)

Example 7 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class ColocOutInterceptorTest method verifyIsColocatedWithSameOperation.

private void verifyIsColocatedWithSameOperation() {
    colocOut = new TestColocOutInterceptor1();
    // Funtion Param
    Server s1 = control.createMock(Server.class);
    List<Server> list = new ArrayList<>();
    list.add(s1);
    Endpoint sep = control.createMock(Endpoint.class);
    BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
    // Local var
    Service ses = control.createMock(Service.class);
    EndpointInfo sei = control.createMock(EndpointInfo.class);
    BindingInfo rbi = control.createMock(BindingInfo.class);
    Endpoint rep = control.createMock(Endpoint.class);
    Service res = control.createMock(Service.class);
    EndpointInfo rei = control.createMock(EndpointInfo.class);
    BindingOperationInfo rboi = control.createMock(BindingOperationInfo.class);
    QName op = new QName("E", "F");
    QName intf = new QName("G", "H");
    QName inmi = new QName("M", "in");
    QName outmi = new QName("M", "out");
    ServiceInfo ssi = new ServiceInfo();
    InterfaceInfo sii = new InterfaceInfo(ssi, intf);
    sii.addOperation(op);
    OperationInfo soi = sii.getOperation(op);
    MessageInfo mii = new MessageInfo(soi, MessageInfo.Type.INPUT, inmi);
    MessageInfo mio = new MessageInfo(soi, MessageInfo.Type.OUTPUT, outmi);
    soi.setInput("in", mii);
    soi.setOutput("out", mio);
    ServiceInfo rsi = new ServiceInfo();
    InterfaceInfo rii = new InterfaceInfo(rsi, intf);
    rii.addOperation(op);
    OperationInfo roi = rii.getOperation(op);
    roi.setInput("in", mii);
    roi.setOutput("out", mio);
    EasyMock.expect(sep.getService()).andReturn(ses);
    EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
    EasyMock.expect(s1.getEndpoint()).andReturn(rep);
    EasyMock.expect(rep.getService()).andReturn(res);
    EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
    EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
    EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
    EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
    EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
    EasyMock.expect(rei.getBinding()).andReturn(rbi);
    EasyMock.expect(sboi.getName()).andReturn(op);
    EasyMock.expect(sboi.getOperationInfo()).andReturn(soi);
    EasyMock.expect(rboi.getName()).andReturn(op);
    EasyMock.expect(rboi.getOperationInfo()).andReturn(roi);
    EasyMock.expect(rbi.getOperation(op)).andReturn(rboi);
    control.replay();
    Server val = colocOut.isColocated(list, sep, sboi);
    assertEquals("Expecting a colocated call", s1, val);
    control.reset();
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Server(org.apache.cxf.endpoint.Server) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service) MessageInfo(org.apache.cxf.service.model.MessageInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Example 8 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class ColocOutInterceptorTest method verifyIsColocatedWithCompatibleOperation.

private void verifyIsColocatedWithCompatibleOperation() {
    colocOut = new TestColocOutInterceptor1();
    // Funtion Param
    Server s1 = control.createMock(Server.class);
    List<Server> list = new ArrayList<>();
    list.add(s1);
    Endpoint sep = control.createMock(Endpoint.class);
    BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
    // Local var
    Service ses = control.createMock(Service.class);
    EndpointInfo sei = control.createMock(EndpointInfo.class);
    BindingInfo rbi = control.createMock(BindingInfo.class);
    Endpoint rep = control.createMock(Endpoint.class);
    Service res = control.createMock(Service.class);
    EndpointInfo rei = control.createMock(EndpointInfo.class);
    BindingOperationInfo rboi = control.createMock(BindingOperationInfo.class);
    QName op = new QName("E", "F");
    QName intf = new QName("G", "H");
    QName inmi = new QName("M", "in");
    QName outmi = new QName("M", "out");
    ServiceInfo ssi = new ServiceInfo();
    InterfaceInfo sii = new InterfaceInfo(ssi, intf);
    sii.addOperation(op);
    OperationInfo soi = sii.getOperation(op);
    MessageInfo mii = new MessageInfo(soi, MessageInfo.Type.INPUT, inmi);
    MessagePartInfo mpi = mii.addMessagePart("parameters");
    mpi.setTypeClass(Source.class);
    MessageInfo mio = new MessageInfo(soi, MessageInfo.Type.OUTPUT, outmi);
    mpi = mio.addMessagePart("parameters");
    mpi.setTypeClass(Source.class);
    soi.setInput("in", mii);
    soi.setOutput("out", mio);
    ServiceInfo rsi = new ServiceInfo();
    InterfaceInfo rii = new InterfaceInfo(rsi, intf);
    rii.addOperation(op);
    OperationInfo roi = rii.getOperation(op);
    mii = new MessageInfo(roi, MessageInfo.Type.INPUT, inmi);
    mpi = mii.addMessagePart("parameters");
    mpi.setTypeClass(Object.class);
    mio = new MessageInfo(roi, MessageInfo.Type.OUTPUT, outmi);
    mpi = mio.addMessagePart("parameters");
    mpi.setTypeClass(Object.class);
    roi.setInput("in", mii);
    roi.setOutput("out", mio);
    EasyMock.expect(sep.getService()).andReturn(ses);
    EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
    EasyMock.expect(s1.getEndpoint()).andReturn(rep);
    EasyMock.expect(rep.getService()).andReturn(res);
    EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
    EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
    EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
    EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
    EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
    EasyMock.expect(rei.getBinding()).andReturn(rbi);
    EasyMock.expect(sboi.getName()).andReturn(op);
    EasyMock.expect(sboi.getOperationInfo()).andReturn(soi);
    EasyMock.expect(rboi.getName()).andReturn(op);
    EasyMock.expect(rboi.getOperationInfo()).andReturn(roi);
    EasyMock.expect(rbi.getOperation(op)).andReturn(rboi);
    control.replay();
    Server val = colocOut.isColocated(list, sep, sboi);
    assertEquals("Expecting a colocated call", s1, val);
    control.reset();
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Server(org.apache.cxf.endpoint.Server) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Example 9 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class CodeFirstTest method createService.

private Definition createService(boolean wrapped) throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    Bus bus = getBus();
    bean.setBus(bus);
    bean.setServiceClass(Hello.class);
    bean.setWrapped(wrapped);
    Service service = bean.create();
    InterfaceInfo i = service.getServiceInfos().get(0).getInterface();
    assertEquals(5, i.getOperations().size());
    ServerFactoryBean svrFactory = new ServerFactoryBean();
    svrFactory.setBus(bus);
    svrFactory.setServiceFactory(bean);
    svrFactory.setAddress(address);
    svrFactory.create();
    Collection<BindingInfo> bindings = service.getServiceInfos().get(0).getBindings();
    assertEquals(1, bindings.size());
    ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, service.getServiceInfos().get(0));
    return wsdlBuilder.build();
}
Also used : Bus(org.apache.cxf.Bus) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BindingInfo(org.apache.cxf.service.model.BindingInfo) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) GenericsService(org.apache.cxf.jaxws.service.GenericsService) ArrayService(org.apache.cxf.jaxws.service.ArrayService) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) ServiceWSDLBuilder(org.apache.cxf.wsdl11.ServiceWSDLBuilder)

Example 10 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class WrapperClassGeneratorTest method testForXmlList.

@org.junit.Test
public void testForXmlList() throws Exception {
    JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(AddNumbersImpl.class);
    JaxWsServiceFactoryBean jaxwsFac = new JaxWsServiceFactoryBean(implInfo);
    jaxwsFac.setBus(BusFactory.getDefaultBus());
    Service service = jaxwsFac.create();
    ServiceInfo serviceInfo = service.getServiceInfos().get(0);
    InterfaceInfo interfaceInfo = serviceInfo.getInterface();
    OperationInfo inf = interfaceInfo.getOperations().iterator().next();
    Class<?> requestClass = inf.getInput().getMessagePart(0).getTypeClass();
    Class<?> responseClass = inf.getOutput().getMessagePart(0).getTypeClass();
    // Create request wrapper Object
    List<String> partNames = Arrays.asList(new String[] { "arg0" });
    List<String> elTypeNames = Arrays.asList(new String[] { "list" });
    List<Class<?>> partClasses = Arrays.asList(new Class<?>[] { List.class });
    String className = requestClass.getName();
    className = className.substring(0, className.lastIndexOf(".") + 1);
    WrapperHelper wh = new JAXBDataBinding().createWrapperHelper(requestClass, null, partNames, elTypeNames, partClasses);
    List<Object> paraList = new ArrayList<>();
    List<String> valueList = new ArrayList<>();
    valueList.add("str1");
    valueList.add("str2");
    valueList.add("str3");
    paraList.add(valueList);
    Object requestObj = wh.createWrapperObject(paraList);
    // Create response wrapper Object
    partNames = Arrays.asList(new String[] { "return" });
    elTypeNames = Arrays.asList(new String[] { "list" });
    partClasses = Arrays.asList(new Class<?>[] { List.class });
    className = responseClass.getName();
    className = className.substring(0, className.lastIndexOf(".") + 1);
    wh = new JAXBDataBinding().createWrapperHelper(responseClass, null, partNames, elTypeNames, partClasses);
    List<Object> resPara = new ArrayList<>();
    List<Integer> intValueList = new ArrayList<>();
    intValueList.add(1);
    intValueList.add(2);
    intValueList.add(3);
    resPara.add(intValueList);
    Object responseObj = wh.createWrapperObject(resPara);
    JAXBContext jaxbContext = JAXBContext.newInstance(requestClass, responseClass);
    java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream();
    Marshaller marshaller = jaxbContext.createMarshaller();
    // check marshall wrapper
    marshaller.marshal(requestObj, bout);
    String expected = "<arg0>str1 str2 str3</arg0>";
    assertTrue("The generated request wrapper class does not contain the correct annotations", bout.toString().contains(expected));
    bout.reset();
    marshaller.marshal(responseObj, bout);
    expected = "<return>1</return><return>2</return><return>3</return>";
    assertTrue("The generated response wrapper class is not correct", bout.toString().contains(expected));
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) ArrayList(java.util.ArrayList) JAXBContext(javax.xml.bind.JAXBContext) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) WrapperHelper(org.apache.cxf.databinding.WrapperHelper) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) ArrayList(java.util.ArrayList) List(java.util.List) Marshaller(javax.xml.bind.Marshaller) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) Service(org.apache.cxf.service.Service) JaxWsImplementorInfo(org.apache.cxf.jaxws.support.JaxWsImplementorInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Aggregations

InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)52 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)32 OperationInfo (org.apache.cxf.service.model.OperationInfo)30 QName (javax.xml.namespace.QName)25 Test (org.junit.Test)23 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)21 Service (org.apache.cxf.service.Service)20 Endpoint (org.apache.cxf.endpoint.Endpoint)19 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)17 BindingInfo (org.apache.cxf.service.model.BindingInfo)16 Method (java.lang.reflect.Method)15 ArrayList (java.util.ArrayList)10 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)9 Bus (org.apache.cxf.Bus)8 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)7 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)7 List (java.util.List)5 WebService (javax.jws.WebService)5 MessageInfo (org.apache.cxf.service.model.MessageInfo)5 ReflectionServiceFactoryBean (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)5