Search in sources :

Example 41 with BindingOperationInfo

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

the class ServiceWSDLBuilder method buildBindingOperation.

protected void buildBindingOperation(Definition def, Binding binding, Collection<BindingOperationInfo> bindingOperationInfos) {
    BindingOperation bindingOperation = null;
    for (BindingOperationInfo bindingOperationInfo : bindingOperationInfos) {
        bindingOperation = def.createBindingOperation();
        addDocumentation(bindingOperation, bindingOperationInfo.getDocumentation());
        bindingOperation.setName(bindingOperationInfo.getName().getLocalPart());
        for (Operation operation : CastUtils.cast(binding.getPortType().getOperations(), Operation.class)) {
            if (operation.getName().equals(bindingOperation.getName())) {
                bindingOperation.setOperation(operation);
                break;
            }
        }
        buildBindingInput(def, bindingOperation, bindingOperationInfo.getInput());
        buildBindingOutput(def, bindingOperation, bindingOperationInfo.getOutput());
        buildBindingFault(def, bindingOperation, bindingOperationInfo.getFaults());
        addExtensibilityAttributes(def, bindingOperation, bindingOperationInfo.getExtensionAttributes());
        addExtensibilityElements(def, bindingOperation, getWSDL11Extensors(bindingOperationInfo));
        binding.addBindingOperation(bindingOperation);
    }
}
Also used : BindingOperation(javax.wsdl.BindingOperation) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation)

Example 42 with BindingOperationInfo

use of org.apache.cxf.service.model.BindingOperationInfo 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();
            }
            BindingOperationInfo bop2 = null;
            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 43 with BindingOperationInfo

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

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

the class WSDLServiceBuilderTest method testBare.

@Test
public void testBare() throws Exception {
    setUpWSDL(BARE_WSDL_PATH, 0);
    BindingInfo bindingInfo = null;
    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)

Example 45 with BindingOperationInfo

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

the class WSDLServiceBuilderTest method testBindingMessageInfo.

@Test
public void testBindingMessageInfo() throws Exception {
    setUpBasic();
    BindingInfo bindingInfo = null;
    bindingInfo = serviceInfo.getBindings().iterator().next();
    QName name = new QName(serviceInfo.getName().getNamespaceURI(), "sayHi");
    BindingOperationInfo sayHi = bindingInfo.getOperation(name);
    BindingMessageInfo input = sayHi.getInput();
    assertNotNull(input);
    assertEquals(input.getMessageInfo().getName().getLocalPart(), "sayHiRequest");
    assertEquals(input.getMessageInfo().getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
    assertEquals(input.getMessageInfo().getMessageParts().size(), 1);
    assertEquals(input.getMessageInfo().getMessageParts().get(0).getName().getLocalPart(), "in");
    assertEquals(input.getMessageInfo().getMessageParts().get(0).getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
    assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement());
    QName elementName = input.getMessageInfo().getMessageParts().get(0).getElementQName();
    assertEquals(elementName.getLocalPart(), "sayHi");
    assertEquals(elementName.getNamespaceURI(), "http://apache.org/hello_world_soap_http/types");
    BindingMessageInfo output = sayHi.getOutput();
    assertNotNull(output);
    assertEquals(output.getMessageInfo().getName().getLocalPart(), "sayHiResponse");
    assertEquals(output.getMessageInfo().getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
    assertEquals(output.getMessageInfo().getMessageParts().size(), 1);
    assertEquals(output.getMessageInfo().getMessageParts().get(0).getName().getLocalPart(), "out");
    assertEquals(output.getMessageInfo().getMessageParts().get(0).getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
    assertTrue(output.getMessageInfo().getMessageParts().get(0).isElement());
    elementName = output.getMessageInfo().getMessageParts().get(0).getElementQName();
    assertEquals(elementName.getLocalPart(), "sayHiResponse");
    assertEquals(elementName.getNamespaceURI(), "http://apache.org/hello_world_soap_http/types");
    assertTrue(sayHi.getFaults().isEmpty());
    name = new QName(serviceInfo.getName().getNamespaceURI(), "pingMe");
    BindingOperationInfo pingMe = bindingInfo.getOperation(name);
    assertNotNull(pingMe);
    assertEquals(1, pingMe.getFaults().size());
    BindingFaultInfo fault = pingMe.getFaults().iterator().next();
    assertNotNull(fault);
    assertEquals(fault.getFaultInfo().getName().getLocalPart(), "pingMeFault");
    assertEquals(fault.getFaultInfo().getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
    assertEquals(fault.getFaultInfo().getMessageParts().size(), 1);
    assertEquals(fault.getFaultInfo().getMessageParts().get(0).getName().getLocalPart(), "faultDetail");
    assertEquals(fault.getFaultInfo().getMessageParts().get(0).getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
    assertTrue(fault.getFaultInfo().getMessageParts().get(0).isElement());
    elementName = fault.getFaultInfo().getMessageParts().get(0).getElementQName();
    assertEquals(elementName.getLocalPart(), "faultDetail");
    assertEquals(elementName.getNamespaceURI(), "http://apache.org/hello_world_soap_http/types");
    control.verify();
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) Test(org.junit.Test)

Aggregations

BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)214 QName (javax.xml.namespace.QName)82 BindingInfo (org.apache.cxf.service.model.BindingInfo)57 Test (org.junit.Test)55 Exchange (org.apache.cxf.message.Exchange)50 OperationInfo (org.apache.cxf.service.model.OperationInfo)47 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)42 Endpoint (org.apache.cxf.endpoint.Endpoint)41 Message (org.apache.cxf.message.Message)36 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)36 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)32 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)31 Service (org.apache.cxf.service.Service)29 Fault (org.apache.cxf.interceptor.Fault)24 MessageInfo (org.apache.cxf.service.model.MessageInfo)24 MessageContentsList (org.apache.cxf.message.MessageContentsList)23 Method (java.lang.reflect.Method)22 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)22 ArrayList (java.util.ArrayList)21 BindingFaultInfo (org.apache.cxf.service.model.BindingFaultInfo)16