Search in sources :

Example 86 with BindingInfo

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

the class RMCaptureOutInterceptor method setTerminateSequence.

private void setTerminateSequence(Message msg, Identifier identifier, ProtocolVariation protocol) throws RMException {
    TerminateSequenceType ts = new TerminateSequenceType();
    ts.setIdentifier(identifier);
    MessageContentsList contents = new MessageContentsList(new Object[] { protocol.getCodec().convertToSend(ts) });
    msg.setContent(List.class, contents);
    // create a new exchange for this output-only exchange
    Exchange newex = new ExchangeImpl();
    Exchange oldex = msg.getExchange();
    newex.put(Bus.class, oldex.getBus());
    newex.put(Endpoint.class, oldex.getEndpoint());
    newex.put(Service.class, oldex.getEndpoint().getService());
    newex.put(Binding.class, oldex.getEndpoint().getBinding());
    newex.setConduit(oldex.getConduit(msg));
    newex.setDestination(oldex.getDestination());
    // Setup the BindingOperationInfo
    RMEndpoint rmep = getManager().getReliableEndpoint(msg);
    OperationInfo oi = rmep.getEndpoint(protocol).getEndpointInfo().getService().getInterface().getOperation(protocol.getConstants().getTerminateSequenceAnonymousOperationName());
    BindingInfo bi = rmep.getBindingInfo(protocol);
    BindingOperationInfo boi = bi.getOperation(oi);
    newex.put(BindingInfo.class, bi);
    newex.put(BindingOperationInfo.class, boi);
    msg.setExchange(newex);
    newex.setOutMessage(msg);
}
Also used : Exchange(org.apache.cxf.message.Exchange) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) MessageContentsList(org.apache.cxf.message.MessageContentsList) BindingInfo(org.apache.cxf.service.model.BindingInfo) TerminateSequenceType(org.apache.cxf.ws.rm.v200702.TerminateSequenceType) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 87 with BindingInfo

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

the class ReflectionServiceFactoryBean method initializeWSDLOperations.

protected void initializeWSDLOperations() {
    List<OperationInfo> removes = new ArrayList<>();
    Method[] methods = serviceClass.getMethods();
    Arrays.sort(methods, new MethodComparator());
    InterfaceInfo intf = getInterfaceInfo();
    Map<QName, Method> validMethods = new HashMap<>();
    for (Method m : methods) {
        if (isValidMethod(m)) {
            QName opName = getOperationName(intf, m);
            validMethods.put(opName, m);
        }
    }
    for (OperationInfo o : intf.getOperations()) {
        Method selected = null;
        for (Map.Entry<QName, Method> m : validMethods.entrySet()) {
            QName opName = m.getKey();
            if (o.getName().getNamespaceURI().equals(opName.getNamespaceURI()) && isMatchOperation(o.getName().getLocalPart(), opName.getLocalPart())) {
                selected = m.getValue();
                break;
            }
        }
        if (selected == null) {
            LOG.log(Level.WARNING, "NO_METHOD_FOR_OP", o.getName());
            removes.add(o);
        } else {
            initializeWSDLOperation(intf, o, selected);
        }
    }
    for (OperationInfo op : removes) {
        intf.removeOperation(op);
    }
    // Update the bindings.
    for (ServiceInfo service : getService().getServiceInfos()) {
        for (BindingInfo bi : service.getBindings()) {
            List<BindingOperationInfo> biremoves = new ArrayList<>();
            for (BindingOperationInfo binfo : bi.getOperations()) {
                if (removes.contains(binfo.getOperationInfo())) {
                    biremoves.add(binfo);
                } else {
                    binfo.updateUnwrappedOperation();
                }
            }
            for (BindingOperationInfo binfo : biremoves) {
                bi.removeOperation(binfo);
            }
        }
    }
    sendEvent(Event.INTERFACE_CREATED, intf, getServiceClass());
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) UnwrappedOperationInfo(org.apache.cxf.service.model.UnwrappedOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) NamespaceMap(org.apache.ws.commons.schema.utils.NamespaceMap)

Example 88 with BindingInfo

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

the class WSDLServiceBuilder method buildServices.

private List<ServiceInfo> buildServices(Definition def, Service serv, QName endpointName, DescriptionInfo d) {
    Map<QName, ServiceInfo> services = new LinkedHashMap<>();
    DescriptionInfo description = d;
    if (null == description) {
        description = new DescriptionInfo();
        if (recordOriginal) {
            description.setProperty(WSDL_DEFINITION, def);
        }
        description.setName(def.getQName());
        description.setBaseURI(def.getDocumentBaseURI());
        copyExtensors(description, def.getExtensibilityElements());
        copyExtensionAttributes(description, def);
        Set<Definition> done = new HashSet<>();
        done.add(def);
        Collection<List<Import>> values = CastUtils.cast(def.getImports().values());
        for (List<Import> imports : values) {
            for (Import imp : imports) {
                if (!done.contains(imp.getDefinition())) {
                    done.add(imp.getDefinition());
                    copyExtensors(description, imp.getExtensibilityElements());
                    copyExtensionAttributes(description, imp);
                    copyExtensors(description, imp.getDefinition().getExtensibilityElements());
                    copyExtensionAttributes(description, imp.getDefinition());
                }
            }
        }
    }
    for (Port port : cast(serv.getPorts().values(), Port.class)) {
        if (endpointName != null && !endpointName.getLocalPart().equals(port.getName())) {
            continue;
        }
        Binding binding = port.getBinding();
        PortType bindingPt = binding.getPortType();
        if (bindingPt == null) {
            org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("BINDING_MISSING_TYPE", LOG, binding.getQName());
            throw new WSDLRuntimeException(msg);
        }
        // TODO: wsdl4j's bug. if there is recursive import,
        // wsdl4j can not get operation input message
        PortType pt = def.getPortType(bindingPt.getQName());
        if (pt == null) {
            pt = bindingPt;
        }
        ServiceInfo service = services.get(pt.getQName());
        if (service == null) {
            service = new ServiceInfo();
            service.setDescription(description);
            description.getDescribed().add(service);
            if (recordOriginal) {
                service.setProperty(WSDL_DEFINITION, def);
                service.setProperty(WSDL_SERVICE, serv);
            }
            getSchemas(def, service);
            copyDocumentation(service, serv);
            service.setProperty(WSDL_SCHEMA_ELEMENT_LIST, this.schemaList);
            service.setTargetNamespace(def.getTargetNamespace());
            service.setName(serv.getQName());
            copyExtensors(service, serv.getExtensibilityElements());
            copyExtensionAttributes(service, serv);
            buildInterface(service, pt);
            services.put(pt.getQName(), service);
        }
        BindingInfo bi = service.getBinding(binding.getQName());
        if (bi == null) {
            bi = buildBinding(service, binding);
        }
        buildEndpoint(service, bi, port);
    }
    return new ArrayList<>(services.values());
}
Also used : Import(javax.wsdl.Import) Message(javax.wsdl.Message) Port(javax.wsdl.Port) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) List(java.util.List) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) PortType(javax.wsdl.PortType)

Example 89 with BindingInfo

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

the class SimpleBatchSTSClient method findOperation.

protected BindingOperationInfo findOperation(String suffix) {
    BindingInfo bi = client.getEndpoint().getBinding().getBindingInfo();
    for (BindingOperationInfo boi : bi.getOperations()) {
        SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
        if (soi != null && soi.getAction() != null && soi.getAction().endsWith(suffix)) {
            PolicyEngine pe = bus.getExtension(PolicyEngine.class);
            Conduit conduit = client.getConduit();
            EffectivePolicy effectivePolicy = pe.getEffectiveClientRequestPolicy(client.getEndpoint().getEndpointInfo(), boi, conduit, PhaseInterceptorChain.getCurrentMessage());
            setPolicyInternal(effectivePolicy.getPolicy());
            return boi;
        }
    }
    // we can at least find it by name and then set the action and such manually later.
    for (BindingOperationInfo boi : bi.getOperations()) {
        if (boi.getInput().getMessageInfo().getMessageParts().size() > 0) {
            MessagePartInfo mpi = boi.getInput().getMessageInfo().getMessagePart(0);
            if ("RequestSecurityToken".equals(mpi.getConcreteName().getLocalPart())) {
                return boi;
            }
        }
    }
    return null;
}
Also used : EffectivePolicy(org.apache.cxf.ws.policy.EffectivePolicy) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Conduit(org.apache.cxf.transport.Conduit) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) PolicyEngine(org.apache.cxf.ws.policy.PolicyEngine) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Example 90 with BindingInfo

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

the class JaxwsServiceBuilderTest method testCXF669.

@Test
public void testCXF669() throws Exception {
    boolean oldSetting = generator.allowImports();
    generator.setAllowImports(true);
    builder.setServiceClass(org.apache.cxf.tools.fortest.cxf669.HelloImpl.class);
    ServiceInfo service = builder.createService();
    assertNotNull(service);
    assertEquals(new QName("http://foo.com/HelloWorldService", "HelloService"), service.getName());
    assertEquals(new QName("http://foo.com/HelloWorld", "HelloWorld"), service.getInterface().getName());
    assertEquals(1, service.getSchemas().size());
    assertEquals("http://foo.com/HelloWorld", service.getSchemas().iterator().next().getNamespaceURI());
    Collection<BindingInfo> bindings = service.getBindings();
    assertEquals(1, bindings.size());
    assertEquals(new QName("http://foo.com/HelloWorldService", "HelloServiceSoapBinding"), bindings.iterator().next().getName());
    generator.setServiceModel(service);
    File wsdl = getOutputFile("HelloService.wsdl");
    assertNotNull(wsdl);
    generator.generate(wsdl);
    assertTrue(wsdl.exists());
    File logical = new File(output, "HelloWorld.wsdl");
    assertTrue(logical.exists());
    File schema = new File(output, "HelloService_schema1.xsd");
    assertTrue(schema.exists());
    String s = new String(Files.readAllBytes(wsdl.toPath()));
    assertTrue(s.indexOf("<wsdl:import namespace=\"http://foo.com/HelloWorld\" " + "location=\"HelloWorld.wsdl\">") != -1);
    assertTrue(s.indexOf("targetNamespace=\"http://foo.com/HelloWorldService\"") != -1);
    s = new String(Files.readAllBytes(logical.toPath()));
    assertTrue(s.indexOf("<import namespace=\"http://foo.com/HelloWorld\"") != -1);
    assertTrue(s.indexOf("schemaLocation=\"HelloService_schema1.xsd\"/>") != -1);
    assertTrue(s.indexOf("targetNamespace=\"http://foo.com/HelloWorld\"") != -1);
    s = new String(Files.readAllBytes(schema.toPath()));
    assertTrue(s.indexOf("targetNamespace=\"http://foo.com/HelloWorld\"") != -1);
    generator.setAllowImports(oldSetting);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo) File(java.io.File) Test(org.junit.Test)

Aggregations

BindingInfo (org.apache.cxf.service.model.BindingInfo)103 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)65 QName (javax.xml.namespace.QName)45 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)44 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)35 Test (org.junit.Test)29 Endpoint (org.apache.cxf.endpoint.Endpoint)28 OperationInfo (org.apache.cxf.service.model.OperationInfo)21 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)20 Service (org.apache.cxf.service.Service)18 SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)17 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)17 Exchange (org.apache.cxf.message.Exchange)15 Message (org.apache.cxf.message.Message)13 ArrayList (java.util.ArrayList)11 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)11 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)11 MessageImpl (org.apache.cxf.message.MessageImpl)11 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)9 Bus (org.apache.cxf.Bus)8