Search in sources :

Example 46 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo 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 47 with BindingInfo

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

the class ProxyTest method testInvoke.

@Test
public void testInvoke() throws Exception {
    Method m = Proxy.class.getDeclaredMethod("createClient", new Class[] { Bus.class, Endpoint.class, ProtocolVariation.class, Conduit.class, org.apache.cxf.ws.addressing.EndpointReferenceType.class });
    Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
    proxy.setReliableEndpoint(rme);
    RMManager manager = control.createMock(RMManager.class);
    EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes();
    Bus bus = control.createMock(Bus.class);
    EasyMock.expect(manager.getBus()).andReturn(bus).anyTimes();
    Endpoint endpoint = control.createMock(Endpoint.class);
    EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
    BindingInfo bi = control.createMock(BindingInfo.class);
    EasyMock.expect(rme.getBindingInfo(ProtocolVariation.RM10WSA200408)).andReturn(bi).anyTimes();
    Conduit conduit = control.createMock(Conduit.class);
    EasyMock.expect(rme.getConduit()).andReturn(conduit).anyTimes();
    org.apache.cxf.ws.addressing.EndpointReferenceType replyTo = control.createMock(org.apache.cxf.ws.addressing.EndpointReferenceType.class);
    EasyMock.expect(rme.getReplyTo()).andReturn(replyTo).anyTimes();
    OperationInfo oi = control.createMock(OperationInfo.class);
    BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
    EasyMock.expect(bi.getOperation(oi)).andReturn(boi).anyTimes();
    Client client = control.createMock(Client.class);
    EasyMock.expect(client.getRequestContext()).andReturn(new HashMap<String, Object>()).anyTimes();
    EasyMock.expect(proxy.createClient(bus, endpoint, ProtocolVariation.RM10WSA200408, conduit, replyTo)).andReturn(client).anyTimes();
    Object[] args = new Object[] {};
    Map<String, Object> context = new HashMap<>();
    Object[] results = new Object[] { "a", "b", "c" };
    Exchange exchange = control.createMock(Exchange.class);
    EasyMock.expect(client.invoke(boi, args, context, exchange)).andReturn(results).anyTimes();
    control.replay();
    assertEquals("a", proxy.invoke(oi, ProtocolVariation.RM10WSA200408, args, context, exchange));
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) HashMap(java.util.HashMap) Method(java.lang.reflect.Method) Exchange(org.apache.cxf.message.Exchange) 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) Test(org.junit.Test)

Example 48 with BindingInfo

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

the class WSDLServiceBuilder method buildBinding.

public BindingInfo buildBinding(ServiceInfo service, Binding binding) {
    BindingInfo bi = null;
    StringBuilder ns = new StringBuilder(100);
    BindingFactory factory = WSDLServiceUtils.getBindingFactory(binding, bus, ns);
    if (factory instanceof WSDLBindingFactory) {
        WSDLBindingFactory wFactory = (WSDLBindingFactory) factory;
        bi = wFactory.createBindingInfo(service, binding, ns.toString());
        copyExtensors(bi, binding.getExtensibilityElements());
        copyExtensionAttributes(bi, binding);
    }
    if (bi == null) {
        boolean onlyExtensors = false;
        if (factory instanceof AbstractBindingFactory) {
            bi = ((AbstractBindingFactory) factory).createBindingInfo(service, ns.toString(), null);
            onlyExtensors = true;
        } else {
            bi = new BindingInfo(service, ns.toString());
        }
        bi.setName(binding.getQName());
        copyExtensors(bi, binding.getExtensibilityElements());
        copyExtensionAttributes(bi, binding);
        for (BindingOperation bop : cast(binding.getBindingOperations(), BindingOperation.class)) {
            if (LOG.isLoggable(Level.FINER)) {
                LOG.finer("binding operation name is " + bop.getName());
            }
            String inName = null;
            String outName = null;
            if (bop.getBindingInput() != null) {
                inName = bop.getBindingInput().getName();
            }
            if (bop.getBindingOutput() != null) {
                outName = bop.getBindingOutput().getName();
            }
            final BindingOperationInfo bop2;
            if (onlyExtensors) {
                bop2 = bi.getOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()));
            } else {
                bop2 = bi.buildOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()), inName, outName);
                if (bop2 != null) {
                    bi.addOperation(bop2);
                }
            }
            if (bop2 != null) {
                copyExtensors(bop2, bop.getExtensibilityElements());
                copyExtensionAttributes(bop2, bop);
                if (bop.getBindingInput() != null) {
                    copyExtensors(bop2.getInput(), bop.getBindingInput().getExtensibilityElements());
                    copyExtensionAttributes(bop2.getInput(), bop.getBindingInput());
                    handleHeader(bop2.getInput());
                }
                if (bop.getBindingOutput() != null) {
                    copyExtensors(bop2.getOutput(), bop.getBindingOutput().getExtensibilityElements());
                    copyExtensionAttributes(bop2.getOutput(), bop.getBindingOutput());
                    handleHeader(bop2.getOutput());
                }
                for (BindingFault f : cast(bop.getBindingFaults().values(), BindingFault.class)) {
                    BindingFaultInfo bif = bop2.getFault(new QName(service.getTargetNamespace(), f.getName()));
                    copyExtensors(bif, bop.getBindingFault(f.getName()).getExtensibilityElements());
                    copyExtensionAttributes(bif, bop.getBindingFault(f.getName()));
                }
            }
        }
    }
    service.addBinding(bi);
    DescriptionInfo d = service.getDescription();
    if (null != d) {
        d.getDescribed().add(bi);
    }
    return bi;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingFault(javax.wsdl.BindingFault) QName(javax.xml.namespace.QName) WSDLBindingFactory(org.apache.cxf.wsdl.binding.WSDLBindingFactory) AbstractBindingFactory(org.apache.cxf.binding.AbstractBindingFactory) BindingOperation(javax.wsdl.BindingOperation) BindingInfo(org.apache.cxf.service.model.BindingInfo) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) WSDLBindingFactory(org.apache.cxf.wsdl.binding.WSDLBindingFactory) AbstractBindingFactory(org.apache.cxf.binding.AbstractBindingFactory) BindingFactory(org.apache.cxf.binding.BindingFactory)

Example 49 with BindingInfo

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

the class DocLiteralInInterceptorTest method testUnmarshalSourceData.

@Test
public void testUnmarshalSourceData() throws Exception {
    XMLStreamReader reader = StaxUtils.createXMLStreamReader(getClass().getResourceAsStream("resources/multiPartDocLitBareReq.xml"));
    assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag());
    XMLStreamReader filteredReader = new PartialXMLStreamReader(reader, new QName("http://schemas.xmlsoap.org/soap/envelope/", "Body"));
    // advance the xml reader to the message parts
    StaxUtils.read(filteredReader);
    assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag());
    Message m = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    Service service = control.createMock(Service.class);
    exchange.put(Service.class, service);
    EasyMock.expect(service.getDataBinding()).andReturn(new SourceDataBinding());
    EasyMock.expect(service.size()).andReturn(0).anyTimes();
    EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();
    Endpoint endpoint = control.createMock(Endpoint.class);
    exchange.put(Endpoint.class, endpoint);
    OperationInfo operationInfo = new OperationInfo();
    operationInfo.setProperty("operation.is.synthetic", Boolean.TRUE);
    MessageInfo messageInfo = new MessageInfo(operationInfo, Type.INPUT, new QName("http://foo.com", "bar"));
    messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo1"), null));
    messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo2"), null));
    messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo3"), null));
    messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo4"), null));
    for (MessagePartInfo mpi : messageInfo.getMessageParts()) {
        mpi.setMessageContainer(messageInfo);
    }
    operationInfo.setInput("inputName", messageInfo);
    BindingOperationInfo boi = new BindingOperationInfo(null, operationInfo);
    exchange.put(BindingOperationInfo.class, boi);
    EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
    BindingInfo binding = control.createMock(BindingInfo.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes();
    EasyMock.expect(endpointInfo.getBinding()).andReturn(binding).anyTimes();
    EasyMock.expect(binding.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
    EasyMock.expect(endpointInfo.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
    EasyMock.expect(endpoint.size()).andReturn(0).anyTimes();
    EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();
    ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
    EasyMock.expect(endpointInfo.getService()).andReturn(serviceInfo).anyTimes();
    EasyMock.expect(serviceInfo.getName()).andReturn(new QName("http://foo.com", "service")).anyTimes();
    InterfaceInfo interfaceInfo = control.createMock(InterfaceInfo.class);
    EasyMock.expect(serviceInfo.getInterface()).andReturn(interfaceInfo).anyTimes();
    EasyMock.expect(interfaceInfo.getName()).andReturn(new QName("http://foo.com", "interface")).anyTimes();
    EasyMock.expect(endpointInfo.getName()).andReturn(new QName("http://foo.com", "endpoint")).anyTimes();
    EasyMock.expect(endpointInfo.getProperty("URI", URI.class)).andReturn(new URI("dummy")).anyTimes();
    List<OperationInfo> operations = new ArrayList<>();
    EasyMock.expect(interfaceInfo.getOperations()).andReturn(operations).anyTimes();
    m.setExchange(exchange);
    m.put(Message.SCHEMA_VALIDATION_ENABLED, false);
    m.setContent(XMLStreamReader.class, reader);
    control.replay();
    new DocLiteralInInterceptor().handleMessage(m);
    MessageContentsList params = (MessageContentsList) m.getContent(List.class);
    assertEquals(4, params.size());
    assertEquals("StringDefaultInputElem", ((DOMSource) params.get(0)).getNode().getFirstChild().getNodeName());
    assertEquals("IntParamInElem", ((DOMSource) params.get(1)).getNode().getFirstChild().getNodeName());
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) XMLStreamReader(javax.xml.stream.XMLStreamReader) PartialXMLStreamReader(org.apache.cxf.staxutils.PartialXMLStreamReader) PartialXMLStreamReader(org.apache.cxf.staxutils.PartialXMLStreamReader) Message(org.apache.cxf.message.Message) MessageContentsList(org.apache.cxf.message.MessageContentsList) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SourceDataBinding(org.apache.cxf.databinding.source.SourceDataBinding) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) URI(java.net.URI) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) BindingInfo(org.apache.cxf.service.model.BindingInfo) MessageContentsList(org.apache.cxf.message.MessageContentsList) ArrayList(java.util.ArrayList) List(java.util.List) QName(javax.xml.namespace.QName) Service(org.apache.cxf.service.Service) MessageInfo(org.apache.cxf.service.model.MessageInfo) Exchange(org.apache.cxf.message.Exchange) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 50 with BindingInfo

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

the class WSDLServiceBuilderTest method testBare.

@Test
public void testBare() throws Exception {
    setUpWSDL(BARE_WSDL_PATH, 0);
    BindingInfo bindingInfo = serviceInfo.getBindings().iterator().next();
    Collection<BindingOperationInfo> bindingOperationInfos = bindingInfo.getOperations();
    assertNotNull(bindingOperationInfos);
    assertEquals(bindingOperationInfos.size(), 1);
    LOG.info("the binding operation is " + bindingOperationInfos.iterator().next().getName());
    QName name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMe");
    BindingOperationInfo greetMe = bindingInfo.getOperation(name);
    assertNotNull(greetMe);
    assertEquals("greetMe OperationInfo name error", greetMe.getName(), name);
    assertFalse("greetMe should be a Unwrapped operation ", greetMe.isUnwrappedCapable());
    assertNotNull(serviceInfo.getXmlSchemaCollection());
    control.verify();
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo) 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