Java Code Examples for org.apache.cxf.service.Service#getServiceInfos()

The following examples show how to use org.apache.cxf.service.Service#getServiceInfos() . 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: StaxDataBinding.java    From cxf with Apache License 2.0 6 votes vote down vote up
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) {
            public void begin(MessagePartInfo part) {
                if (part.getTypeQName() != null || part.getElementQName() != null) {
                    return;
                }
                part.setTypeQName(Constants.XSD_ANYTYPE);
            }
        } .walk();
    }
}
 
Example 2
Source File: SourceDataBinding.java    From cxf with Apache License 2.0 6 votes vote down vote up
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) {
            public void begin(MessagePartInfo part) {
                if (part.getTypeQName() != null || part.getElementQName() != null) {
                    return;
                }
                part.setTypeQName(Constants.XSD_ANYTYPE);
            }
        } .walk();
    }
}
 
Example 3
Source File: AbstractAegisTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Definition getWSDLDefinition(String string) throws WSDLException {
    ServerRegistry svrMan = getBus().getExtension(ServerRegistry.class);
    for (Server s : svrMan.getServers()) {
        Service svc = s.getEndpoint().getService();
        if (svc.getName().getLocalPart().equals(string)) {
            ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, svc.getServiceInfos());
            return builder.build();
        }
    }
    return null;

}
 
Example 4
Source File: RPCOutInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    super.setUp();
    ServiceInfo si = getMockedServiceModel(this.getClass()
                                           .getResource("/wsdl_soap/hello_world_rpc_lit.wsdl")
            .toString());
    BindingInfo bi = si.getBinding(new QName(TNS, "Greeter_SOAPBinding_RPCLit"));
    BindingOperationInfo boi = bi.getOperation(new QName(TNS, OPNAME));
    boi.getOperationInfo().getOutput().getMessagePartByIndex(0).setIndex(0);
    soapMessage.getExchange().put(BindingOperationInfo.class, boi);

    control.reset();
    Service service = control.createMock(Service.class);
    EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();
    JAXBDataBinding dataBinding = new JAXBDataBinding(MyComplexStruct.class);
    service.getDataBinding();
    EasyMock.expectLastCall().andReturn(dataBinding).anyTimes();
    service.getServiceInfos();
    List<ServiceInfo> list = Arrays.asList(si);
    EasyMock.expectLastCall().andReturn(list).anyTimes();

    soapMessage.getExchange().put(Service.class, service);
    soapMessage.getExchange().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE);
    control.replay();

    MyComplexStruct mcs = new MyComplexStruct();
    mcs.setElem1("elem1");
    mcs.setElem2("elem2");
    mcs.setElem3(45);
    MessageContentsList param = new MessageContentsList();
    param.add(mcs);
    soapMessage.setContent(List.class, param);
}
 
Example 5
Source File: RPCInInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    super.setUp();
    ServiceInfo si = getMockedServiceModel(this.getClass()
                                           .getResource("/wsdl_soap/hello_world_rpc_lit.wsdl")
            .toString());
    BindingInfo bi = si.getBinding(new QName(TNS, "Greeter_SOAPBinding_RPCLit"));
    BindingOperationInfo boi = bi.getOperation(new QName(TNS, OPNAME));
    boi.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(MyComplexStruct.class);
    boi.getOperationInfo().getInput().getMessagePartByIndex(0).setIndex(1);
    boi.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(MyComplexStruct.class);
    boi.getOperationInfo().getOutput().getMessagePartByIndex(0).setIndex(0);
    soapMessage.getExchange().put(BindingOperationInfo.class, boi);

    control.reset();
    Service service = control.createMock(Service.class);
    JAXBDataBinding dataBinding = new JAXBDataBinding(MyComplexStruct.class);
    service.getDataBinding();
    EasyMock.expectLastCall().andReturn(dataBinding).anyTimes();
    service.getServiceInfos();
    List<ServiceInfo> list = Arrays.asList(si);
    EasyMock.expectLastCall().andReturn(list).anyTimes();
    EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();

    soapMessage.getExchange().put(Service.class, service);
    soapMessage.getExchange().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE);
    control.replay();
}
 
Example 6
Source File: ReflectionServiceFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Code elsewhere in this function will fill in the name of the type of an
 * element but not the reference to the type. This function fills in the
 * type references. This does not set the type reference for elements that
 * are declared as refs to other elements. It is a giant pain to find them,
 * since they are not (generally) root elements and the code would have to
 * traverse all the types to find all of them. Users should look them up
 * through the collection, that's what it is for.
 */
private void fillInSchemaCrossreferences() {
    Service service = getService();
    for (ServiceInfo serviceInfo : service.getServiceInfos()) {
        SchemaCollection schemaCollection = serviceInfo.getXmlSchemaCollection();

        // First pass, fill in any types for which we have a name but no
        // type.
        for (SchemaInfo schemaInfo : serviceInfo.getSchemas()) {
            Map<QName, XmlSchemaElement> elementsTable = schemaInfo.getSchema().getElements();
            for (XmlSchemaElement element : elementsTable.values()) {
                if (element.getSchemaType() == null) {
                    QName typeName = element.getSchemaTypeName();
                    if (typeName != null) {
                        XmlSchemaType type = schemaCollection.getTypeByQName(typeName);
                        if (type == null) {
                            Message message = new Message("REFERENCE_TO_UNDEFINED_TYPE", LOG, element
                                .getQName(), typeName, service.getName());
                            LOG.severe(message.toString());
                        } else {
                            element.setSchemaType(type);
                        }
                    }
                }
            }

        }
    }
}
 
Example 7
Source File: ReflectionServiceFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
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);
            }
        }
    }
}
 
Example 8
Source File: ClientImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
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.");
}