Search in sources :

Example 26 with ServiceInfo

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

the class ColocOutInterceptorTest method verifyIsColocatedWithDifferentOperation.

private void verifyIsColocatedWithDifferentOperation() {
    // 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);
    ServiceInfo ssi = control.createMock(ServiceInfo.class);
    EndpointInfo sei = control.createMock(EndpointInfo.class);
    TestBindingInfo rbi = new TestBindingInfo(ssi, "testBinding");
    Endpoint rep = control.createMock(Endpoint.class);
    Service res = control.createMock(Service.class);
    EndpointInfo rei = control.createMock(EndpointInfo.class);
    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(new QName("E", "F"));
    // Causes ConcurrentModification intermittently
    // QName op = new QName("E", "F");
    // EasyMock.expect(rbi.getOperation(op).andReturn(null);
    control.replay();
    Server val = colocOut.isColocated(list, sep, sboi);
    assertEquals("Is not a colocated call", null, val);
    assertEquals("BindingOperation.getOperation was not called", 1, rbi.getOpCount());
    control.reset();
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Server(org.apache.cxf.endpoint.Server) Endpoint(org.apache.cxf.endpoint.Endpoint) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service)

Example 27 with ServiceInfo

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

the class StaxDataBinding method initialize.

public void initialize(Service service) {
    for (ServiceInfo serviceInfo : service.getServiceInfos()) {
        SchemaCollection schemaCollection = serviceInfo.getXmlSchemaCollection();
        if (schemaCollection.getXmlSchemas().length > 1) {
            // Schemas are already populated.
            continue;
        }
        new ServiceModelVisitor(serviceInfo) {

            @Override
            public void begin(MessagePartInfo part) {
                if (part.getTypeQName() != null || part.getElementQName() != null) {
                    return;
                }
                part.setTypeQName(Constants.XSD_ANYTYPE);
            }
        }.walk();
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) SchemaCollection(org.apache.cxf.common.xmlschema.SchemaCollection) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ServiceModelVisitor(org.apache.cxf.service.ServiceModelVisitor)

Example 28 with ServiceInfo

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

the class ClientImpl method findEndpoint.

private EndpointInfo findEndpoint(Service svc, QName port) {
    if (port != null) {
        EndpointInfo epfo = svc.getEndpointInfo(port);
        if (epfo == null) {
            throw new IllegalArgumentException("The service " + svc.getName() + " does not have an endpoint " + port + ".");
        }
        return epfo;
    }
    for (ServiceInfo svcfo : svc.getServiceInfos()) {
        for (EndpointInfo e : svcfo.getEndpoints()) {
            BindingInfo bfo = e.getBinding();
            String bid = bfo.getBindingId();
            if ("http://schemas.xmlsoap.org/wsdl/soap/".equals(bid) || "http://schemas.xmlsoap.org/wsdl/soap12/".equals(bid)) {
                for (Object o : bfo.getExtensors().get()) {
                    try {
                        String s = (String) o.getClass().getMethod("getTransportURI").invoke(o);
                        if (s != null && s.endsWith("http")) {
                            return e;
                        }
                    } catch (Throwable t) {
                    // ignore
                    }
                }
            }
        }
    }
    throw new UnsupportedOperationException("Only document-style SOAP 1.1 and 1.2 http are supported " + "for auto-selection of endpoint; none were found.");
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo)

Example 29 with ServiceInfo

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

the class SoapBindingFactory method addMessageFromBinding.

protected void addMessageFromBinding(ExtensibilityElement ext, BindingOperationInfo bop, boolean isInput) {
    SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);
    ServiceInfo serviceInfo = bop.getBinding().getService();
    if (header != null && header.getMessage() == null) {
        throw new RuntimeException("Problem with WSDL: soap:header element" + " for operation " + bop.getName() + " under binding " + bop.getBinding().getName() + " does not contain a valid message attribute.");
    }
    if (header != null && serviceInfo.getMessage(header.getMessage()) == null) {
        Definition def = (Definition) serviceInfo.getProperty(WSDLServiceBuilder.WSDL_DEFINITION);
        SchemaCollection schemas = serviceInfo.getXmlSchemaCollection();
        if (def != null && schemas != null) {
            QName qn = header.getMessage();
            javax.wsdl.Message msg = findMessage(qn, def);
            if (msg != null) {
                addOutOfBandParts(bop, msg, schemas, isInput, header.getPart());
                serviceInfo.refresh();
            } else {
                throw new RuntimeException("Problem with WSDL: soap:header element" + " for operation " + bop.getName() + " is referring to an undefined wsdl:message element: " + qn);
            }
        }
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) SoapHeader(org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader) SchemaCollection(org.apache.cxf.common.xmlschema.SchemaCollection)

Example 30 with ServiceInfo

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

the class CorbaConduitTest method testBuildRequest.

@Test
public void testBuildRequest() throws Exception {
    CorbaConduit conduit = setupCorbaConduit(false);
    CorbaMessage message = control.createMock(CorbaMessage.class);
    Exchange exchange = control.createMock(Exchange.class);
    EasyMock.expect(message.getExchange());
    EasyMock.expectLastCall().andReturn(exchange);
    ServiceInfo service = control.createMock(ServiceInfo.class);
    EasyMock.expect(exchange.get(ServiceInfo.class)).andReturn(service);
    List<CorbaTypeMap> list = control.createMock(List.class);
    CorbaTypeMap typeMap = control.createMock(CorbaTypeMap.class);
    EasyMock.expect(service.getExtensors(CorbaTypeMap.class)).andReturn(list);
    OperationType opType = control.createMock(OperationType.class);
    conduit.getArguments(message);
    EasyMock.expectLastCall().andReturn(null);
    conduit.getReturn(message);
    EasyMock.expectLastCall().andReturn(null);
    conduit.getExceptionList(conduit.getOperationExceptions(opType, typeMap), message, opType);
    EasyMock.expectLastCall().andReturn(null);
    conduit.getRequest(message, "Hello", null, null, null);
    EasyMock.expectLastCall();
}
Also used : Exchange(org.apache.cxf.message.Exchange) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) Test(org.junit.Test)

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