Search in sources :

Example 71 with ServiceInfo

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

the class ProxyTest method testCreateSequenceResponse.

@Test
public void testCreateSequenceResponse() throws NoSuchMethodException, RMException {
    Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class });
    Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
    proxy.setReliableEndpoint(rme);
    Endpoint endpoint = control.createMock(Endpoint.class);
    EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
    EndpointInfo epi = control.createMock(EndpointInfo.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
    InterfaceInfo ii = control.createMock(InterfaceInfo.class);
    EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
    OperationInfo oi = control.createMock(OperationInfo.class);
    EasyMock.expect(ii.getOperation(RM10Constants.CREATE_SEQUENCE_RESPONSE_ONEWAY_QNAME)).andReturn(oi).anyTimes();
    org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType csr = control.createMock(org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType.class);
    expectInvoke(proxy, oi, null);
    control.replay();
    proxy.createSequenceResponse(csr, ProtocolVariation.RM10WSA200408);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) Method(java.lang.reflect.Method) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Example 72 with ServiceInfo

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

the class ProxyTest method testLastMessage.

@Test
public void testLastMessage() throws NoSuchMethodException, RMException {
    Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class, Level.class });
    Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
    proxy.setReliableEndpoint(rme);
    SourceSequence ss = control.createMock(SourceSequence.class);
    EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    EasyMock.expect(ss.getTarget()).andReturn(null).anyTimes();
    control.replay();
    proxy.lastMessage(ss);
    control.verify();
    control.reset();
    org.apache.cxf.ws.addressing.EndpointReferenceType target = RMUtils.createAnonymousReference();
    EasyMock.expect(ss.getTarget()).andReturn(target).anyTimes();
    control.replay();
    proxy.lastMessage(ss);
    control.verify();
    control.reset();
    target = RMUtils.createReference("http://localhost:9000/greeterPort");
    EasyMock.expect(ss.getTarget()).andReturn(target).anyTimes();
    EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    Endpoint endpoint = control.createMock(Endpoint.class);
    EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
    EndpointInfo epi = control.createMock(EndpointInfo.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
    InterfaceInfo ii = control.createMock(InterfaceInfo.class);
    EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
    OperationInfo oi = control.createMock(OperationInfo.class);
    EasyMock.expect(ii.getOperation(RM10Constants.CLOSE_SEQUENCE_QNAME)).andReturn(oi).anyTimes();
    expectInvokeWithContext(proxy, oi, null);
    control.replay();
    proxy.lastMessage(ss);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Method(java.lang.reflect.Method) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Example 73 with ServiceInfo

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

the class RMEndpointTest method testGetUsingAddressing.

@Test
public void testGetUsingAddressing() {
    EndpointInfo ei = null;
    control.replay();
    assertNull(rme.getUsingAddressing(ei));
    control.verify();
    control.reset();
    ExtensibilityElement ua = control.createMock(ExtensibilityElement.class);
    ei = control.createMock(EndpointInfo.class);
    List<ExtensibilityElement> noExts = new ArrayList<>();
    List<ExtensibilityElement> exts = new ArrayList<>();
    exts.add(ua);
    EasyMock.expect(ei.getExtensors(ExtensibilityElement.class)).andReturn(noExts);
    BindingInfo bi = control.createMock(BindingInfo.class);
    EasyMock.expect(ei.getBinding()).andReturn(bi).times(2);
    EasyMock.expect(bi.getExtensors(ExtensibilityElement.class)).andReturn(noExts);
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(ei.getService()).andReturn(si).times(2);
    EasyMock.expect(si.getExtensors(ExtensibilityElement.class)).andReturn(exts);
    EasyMock.expect(ua.getElementType()).andReturn(Names.WSAW_USING_ADDRESSING_QNAME);
    control.replay();
    assertSame(ua, rme.getUsingAddressing(ei));
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) ArrayList(java.util.ArrayList) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Test(org.junit.Test)

Example 74 with ServiceInfo

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

the class ServiceWSDLBuilder method build.

/**
 * Create the WSDL Definition object and return it. This function respects the
 * setting of {@link #setUseSchemaImports(boolean)}.
 * @param imports A set of schema imports to either reference as imports or read and
 * then inline.
 * @return the WSDL definition
 * @throws WSDLException
 */
public Definition build(Map<String, SchemaInfo> imports) throws WSDLException {
    Definition definition = null;
    try {
        definition = services.get(0).getProperty(WSDLServiceBuilder.WSDL_DEFINITION, Definition.class);
    } catch (ClassCastException e) {
    // ignore
    }
    if (definition == null) {
        ServiceInfo si = services.get(0);
        definition = newDefinition(si.getName(), si.getTargetNamespace());
        addNamespace(WSDLConstants.CONVENTIONAL_TNS_PREFIX, si.getTargetNamespace(), definition);
        addExtensibilityElements(definition, definition, getWSDL11Extensors(si.getDescription()));
        Collection<PortType> portTypes = new HashSet<>();
        for (ServiceInfo service : services) {
            Definition portTypeDef = definition;
            Definition orig = definition;
            if (!isSameTNS(service)) {
                portTypeDef = newDefinition(service.getInterface().getName(), service.getInterface().getName().getNamespaceURI());
                Import wsdlImport = definition.createImport();
                String tns = service.getInterface().getName().getNamespaceURI();
                wsdlImport.setDefinition(portTypeDef);
                wsdlImport.setNamespaceURI(tns);
                wsdlImport.setLocationURI(service.getInterface().getName().getLocalPart() + ".wsdl");
                definition.addImport(wsdlImport);
                addNamespace(getPrefix(tns), tns, definition);
            }
            portTypes.add(buildPortType(service.getInterface(), portTypeDef));
            if (service.getSchemas() != null && service.getSchemas().size() > 0) {
                if (!useSchemaImports) {
                    buildTypes(service.getSchemas(), imports, portTypeDef);
                } else {
                    buildTypesWithSchemaImports(service.getSchemas(), imports, portTypeDef);
                }
            }
            definition = orig;
        }
        for (ServiceInfo service : services) {
            buildBinding(definition, service.getBindings(), portTypes);
            buildService(service, definition);
        }
    }
    return definition;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) XmlSchemaImport(org.apache.ws.commons.schema.XmlSchemaImport) SchemaImport(javax.wsdl.extensions.schema.SchemaImport) Import(javax.wsdl.Import) Definition(javax.wsdl.Definition) PortType(javax.wsdl.PortType) HashSet(java.util.HashSet)

Example 75 with ServiceInfo

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

the class ReflectionServiceFactoryBean method createEndpoints.

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);
            }
        }
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) EndpointException(org.apache.cxf.endpoint.EndpointException) Service(org.apache.cxf.service.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) BusException(org.apache.cxf.BusException)

Aggregations

ServiceInfo (org.apache.cxf.service.model.ServiceInfo)195 QName (javax.xml.namespace.QName)89 Test (org.junit.Test)76 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)63 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)47 BindingInfo (org.apache.cxf.service.model.BindingInfo)43 OperationInfo (org.apache.cxf.service.model.OperationInfo)37 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)36 Service (org.apache.cxf.service.Service)33 Endpoint (org.apache.cxf.endpoint.Endpoint)31 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)29 File (java.io.File)28 ArrayList (java.util.ArrayList)27 Bus (org.apache.cxf.Bus)26 InputStream (java.io.InputStream)23 Definition (javax.wsdl.Definition)20 Method (java.lang.reflect.Method)16 SchemaCollection (org.apache.cxf.common.xmlschema.SchemaCollection)15 HTTPTransportFactory (org.apache.cxf.transport.http.HTTPTransportFactory)15 IOException (java.io.IOException)12