Search in sources :

Example 66 with BindingInfo

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

the class ClientFactoryBeanTest method testClientFactoryBean.

@Test
public void testClientFactoryBean() throws Exception {
    ClientFactoryBean cfBean = new ClientFactoryBean();
    cfBean.setAddress("http://localhost/Hello");
    cfBean.setBus(getBus());
    cfBean.setServiceClass(HelloService.class);
    Client client = cfBean.create();
    assertNotNull(client);
    Service service = client.getEndpoint().getService();
    Map<QName, Endpoint> eps = service.getEndpoints();
    assertEquals(1, eps.size());
    Endpoint ep = eps.values().iterator().next();
    EndpointInfo endpointInfo = ep.getEndpointInfo();
    BindingInfo b = endpointInfo.getService().getBindings().iterator().next();
    assertTrue(b instanceof SoapBindingInfo);
    SoapBindingInfo sb = (SoapBindingInfo) b;
    assertEquals("HelloServiceSoapBinding", b.getName().getLocalPart());
    assertEquals("document", sb.getStyle());
    assertEquals(4, b.getOperations().size());
    BindingOperationInfo bop = b.getOperations().iterator().next();
    SoapOperationInfo sop = bop.getExtensor(SoapOperationInfo.class);
    assertNotNull(sop);
    assertEquals("", sop.getAction());
    assertEquals("document", sop.getStyle());
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) Service(org.apache.cxf.service.Service) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 67 with BindingInfo

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

the class CorbaDestinationTest method testDestination.

@Test
public void testDestination() throws Exception {
    endpointInfo = testUtils.setupServiceInfo("http://cxf.apache.org/bindings/corba/simple", "/wsdl_corbabinding/simpleIdl.wsdl", "SimpleCORBAService", "SimpleCORBAPort");
    CorbaDestination destination = new CorbaDestination(endpointInfo, orbConfig);
    EndpointReferenceType rtype = destination.getAddress();
    assertNotNull("EndpointReferenceType should not be null", rtype);
    BindingInfo bindingInfo = destination.getBindingInfo();
    assertNotNull("BindingInfo should not be null", bindingInfo);
    EndpointInfo e2 = destination.getEndPointInfo();
    assertNotNull("EndpointInfo should not be null", e2);
    Message m = new MessageImpl();
    CorbaServerConduit serverConduit = (CorbaServerConduit) destination.getBackChannel(m);
    assertNotNull("CorbaServerConduit should not be null", serverConduit);
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Message(org.apache.cxf.message.Message) BindingInfo(org.apache.cxf.service.model.BindingInfo) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 68 with BindingInfo

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

the class Proxy method invoke.

Object invoke(OperationInfo oi, ProtocolVariation protocol, Object[] params, Map<String, Object> context, Exchange exchange, Level exceptionLevel) throws RMException {
    if (LOG.isLoggable(Level.INFO)) {
        LOG.log(Level.INFO, "Sending out-of-band RM protocol message {0}.", oi == null ? null : oi.getName());
    }
    RMManager manager = reliableEndpoint.getManager();
    Bus bus = manager.getBus();
    Endpoint endpoint = reliableEndpoint.getEndpoint(protocol);
    BindingInfo bi = reliableEndpoint.getBindingInfo(protocol);
    Conduit c = reliableEndpoint.getConduit();
    final Client client;
    if (params.length > 0 && params[0] instanceof DestinationSequence) {
        EndpointReferenceType acksTo = ((DestinationSequence) params[0]).getAcksTo();
        String acksAddress = acksTo.getAddress().getValue();
        AttributedURIType attrURIType = new AttributedURIType();
        attrURIType.setValue(acksAddress);
        EndpointReferenceType acks = new EndpointReferenceType();
        acks.setAddress(attrURIType);
        client = createClient(bus, endpoint, protocol, c, acks);
        params = new Object[] {};
    } else {
        EndpointReferenceType replyTo = reliableEndpoint.getReplyTo();
        client = createClient(bus, endpoint, protocol, c, replyTo);
    }
    BindingOperationInfo boi = bi.getOperation(oi);
    try {
        if (context != null) {
            client.getRequestContext().putAll(context);
        }
        Object[] result = client.invoke(boi, params, context, exchange);
        if (result != null && result.length > 0) {
            return result[0];
        }
    } catch (Exception ex) {
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("SEND_PROTOCOL_MSG_FAILED_EXC", LOG, oi == null ? null : oi.getName());
        LOG.log(exceptionLevel, msg.toString(), ex);
        throw new RMException(msg, ex);
    }
    return null;
}
Also used : Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Message(org.apache.cxf.message.Message) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) IOException(java.io.IOException) Endpoint(org.apache.cxf.endpoint.Endpoint) Conduit(org.apache.cxf.transport.Conduit) BindingInfo(org.apache.cxf.service.model.BindingInfo) Client(org.apache.cxf.endpoint.Client)

Example 69 with BindingInfo

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

the class STSUtils method createSTSEndpoint.

// CHECKSTYLE:OFF
private static Endpoint createSTSEndpoint(Bus bus, String namespace, String transportId, String location, String soapVersion, Policy policy, QName epName, boolean sc) throws BusException, EndpointException {
    // CHECKSTYLE:ON
    String ns = namespace + "/wsdl";
    ServiceInfo si = new ServiceInfo();
    QName iName = new QName(ns, sc ? "SecureConversationTokenService" : "SecurityTokenService");
    si.setName(iName);
    InterfaceInfo ii = new InterfaceInfo(si, iName);
    OperationInfo ioi = addIssueOperation(ii, namespace, ns);
    OperationInfo coi = addCancelOperation(ii, namespace, ns);
    OperationInfo roi = addRenewOperation(ii, namespace, ns);
    si.setInterface(ii);
    Service service = new ServiceImpl(si);
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    BindingFactory bindingFactory = bfm.getBindingFactory(soapVersion);
    BindingInfo bi = bindingFactory.createBindingInfo(service, soapVersion, null);
    si.addBinding(bi);
    if (transportId == null) {
        ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
        ConduitInitiator ci = cim.getConduitInitiatorForUri(location);
        transportId = ci.getTransportIds().get(0);
    }
    EndpointInfo ei = new EndpointInfo(si, transportId);
    ei.setBinding(bi);
    ei.setName(epName == null ? iName : epName);
    ei.setAddress(location);
    si.addEndpoint(ei);
    if (policy != null) {
        ei.addExtensor(policy);
    }
    BindingOperationInfo boi = bi.getOperation(ioi);
    SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
    if (soi == null) {
        soi = new SoapOperationInfo();
        boi.addExtensor(soi);
    }
    soi.setAction(namespace + (sc ? "/RST/SCT" : "/RST/Issue"));
    boi = bi.getOperation(coi);
    soi = boi.getExtensor(SoapOperationInfo.class);
    if (soi == null) {
        soi = new SoapOperationInfo();
        boi.addExtensor(soi);
    }
    soi.setAction(namespace + (sc ? "/RST/SCT/Cancel" : "/RST/Cancel"));
    boi = bi.getOperation(roi);
    soi = boi.getExtensor(SoapOperationInfo.class);
    if (soi == null) {
        soi = new SoapOperationInfo();
        boi.addExtensor(soi);
    }
    soi.setAction(namespace + (sc ? "/RST/SCT/Renew" : "/RST/Renew"));
    service.setDataBinding(new SourceDataBinding());
    return new EndpointImpl(bus, service, ei);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) ServiceImpl(org.apache.cxf.service.ServiceImpl) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) Service(org.apache.cxf.service.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) SourceDataBinding(org.apache.cxf.databinding.source.SourceDataBinding) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) BindingFactory(org.apache.cxf.binding.BindingFactory)

Example 70 with BindingInfo

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

the class XMLMessageInInterceptor method handleMessage.

public void handleMessage(Message message) throws Fault {
    if (isGET(message)) {
        LOG.fine("XMLMessageInInterceptor skipped in HTTP GET method");
        return;
    }
    Endpoint ep = message.getExchange().getEndpoint();
    XMLStreamReader xsr = message.getContent(XMLStreamReader.class);
    if (xsr == null) {
        return;
    }
    DepthXMLStreamReader reader = new DepthXMLStreamReader(xsr);
    if (!StaxUtils.toNextElement(reader)) {
        throw new Fault(new org.apache.cxf.common.i18n.Message("NO_OPERATION_ELEMENT", LOG));
    }
    Exchange ex = message.getExchange();
    QName startQName = reader.getName();
    // handling xml fault message
    if (startQName.getLocalPart().equals(XMLFault.XML_FAULT_ROOT)) {
        message.getInterceptorChain().abort();
        if (ep.getInFaultObserver() != null) {
            ep.getInFaultObserver().onMessage(message);
            return;
        }
    }
    // handling xml normal inbound message
    BindingOperationInfo boi = ex.getBindingOperationInfo();
    boolean isRequestor = isRequestor(message);
    if (boi == null) {
        BindingInfo service = ep.getEndpointInfo().getBinding();
        boi = getBindingOperationInfo(isRequestor, startQName, service, xsr);
        if (boi != null) {
            ex.put(BindingOperationInfo.class, boi);
            ex.setOneWay(boi.getOperationInfo().isOneWay());
        }
    } else {
        BindingMessageInfo bmi = isRequestor ? boi.getOutput() : boi.getInput();
        if (hasRootNode(bmi, startQName)) {
            try {
                xsr.nextTag();
            } catch (XMLStreamException xse) {
                throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_READ_EXC", LOG));
            }
        }
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) XMLStreamReader(javax.xml.stream.XMLStreamReader) DepthXMLStreamReader(org.apache.cxf.staxutils.DepthXMLStreamReader) Message(org.apache.cxf.message.Message) QName(javax.xml.namespace.QName) XMLFault(org.apache.cxf.binding.xml.XMLFault) Fault(org.apache.cxf.interceptor.Fault) DepthXMLStreamReader(org.apache.cxf.staxutils.DepthXMLStreamReader) Exchange(org.apache.cxf.message.Exchange) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) XMLStreamException(javax.xml.stream.XMLStreamException) BindingInfo(org.apache.cxf.service.model.BindingInfo)

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