Search in sources :

Example 91 with BindingInfo

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

the class WSDLServiceBuilderTest method testExtensions.

@Test
public void testExtensions() throws Exception {
    setUpWSDL("hello_world_ext.wsdl", 0);
    String ns = "http://apache.org/hello_world_soap_http";
    QName pingMeOpName = new QName(ns, "pingMe");
    QName greetMeOpName = new QName(ns, "greetMe");
    QName faultName = new QName(ns, "pingMeFault");
    // portType extensions
    InterfaceInfo ii = serviceInfo.getInterface();
    assertEquals(2, ii.getExtensionAttributes().size());
    assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_BOOLEAN));
    assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_STRING));
    assertEquals(1, ii.getExtensors(UnknownExtensibilityElement.class).size());
    assertEquals(EXTENSION_ELEM, ii.getExtensor(UnknownExtensibilityElement.class).getElementType());
    // portType/operation extensions
    OperationInfo oi = ii.getOperation(pingMeOpName);
    assertPortTypeOperationExtensions(oi, true);
    assertPortTypeOperationExtensions(ii.getOperation(greetMeOpName), false);
    // portType/operation/[input|output|fault] extensions
    assertPortTypeOperationMessageExtensions(oi, true, true, faultName);
    assertPortTypeOperationMessageExtensions(ii.getOperation(greetMeOpName), false, true, null);
    // service extensions
    assertEquals(1, serviceInfo.getExtensionAttributes().size());
    assertNotNull(serviceInfo.getExtensionAttribute(EXTENSION_ATTR_STRING));
    assertEquals(1, serviceInfo.getExtensors(UnknownExtensibilityElement.class).size());
    assertEquals(EXTENSION_ELEM, serviceInfo.getExtensor(UnknownExtensibilityElement.class).getElementType());
    // service/port extensions
    EndpointInfo ei = serviceInfo.getEndpoints().iterator().next();
    assertEquals(1, ei.getExtensionAttributes().size());
    assertNotNull(ei.getExtensionAttribute(EXTENSION_ATTR_STRING));
    assertEquals(1, ei.getExtensors(UnknownExtensibilityElement.class).size());
    assertEquals(EXTENSION_ELEM, ei.getExtensor(UnknownExtensibilityElement.class).getElementType());
    // binding extensions
    BindingInfo bi = ei.getBinding();
    // REVISIT: bug in wsdl4j?
    // getExtensionAttributes on binding element returns an empty map
    // assertEquals(1, bi.getExtensionAttributes().size());
    // assertNotNull(bi.getExtensionAttribute(EXTENSION_ATTR_STRING));
    assertEquals(1, bi.getExtensors(UnknownExtensibilityElement.class).size());
    assertEquals(EXTENSION_ELEM, bi.getExtensor(UnknownExtensibilityElement.class).getElementType());
    // binding/operation extensions
    BindingOperationInfo boi = bi.getOperation(pingMeOpName);
    assertBindingOperationExtensions(boi, true);
    assertBindingOperationExtensions(bi.getOperation(greetMeOpName), false);
    // binding/operation/[input|output|fault] extensions
    assertBindingOperationMessageExtensions(boi, true, true, faultName);
    assertBindingOperationMessageExtensions(bi.getOperation(greetMeOpName), false, true, null);
    control.verify();
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Example 92 with BindingInfo

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

the class WSDLServiceBuilderTest method testBindingOperationInfo.

@Test
public void testBindingOperationInfo() throws Exception {
    setUpBasic();
    BindingInfo bindingInfo = serviceInfo.getBindings().iterator().next();
    Collection<BindingOperationInfo> bindingOperationInfos = bindingInfo.getOperations();
    assertNotNull(bindingOperationInfos);
    assertEquals(bindingOperationInfos.size(), 4);
    LOG.info("the binding operation is " + bindingOperationInfos.iterator().next().getName());
    QName name = new QName(serviceInfo.getName().getNamespaceURI(), "sayHi");
    BindingOperationInfo sayHi = bindingInfo.getOperation(name);
    assertNotNull(sayHi);
    assertEquals(sayHi.getName(), name);
    name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMe");
    BindingOperationInfo greetMe = bindingInfo.getOperation(name);
    assertNotNull(greetMe);
    assertEquals(greetMe.getName(), name);
    name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMeOneWay");
    BindingOperationInfo greetMeOneWay = bindingInfo.getOperation(name);
    assertNotNull(greetMeOneWay);
    assertEquals(greetMeOneWay.getName(), name);
    name = new QName(serviceInfo.getName().getNamespaceURI(), "pingMe");
    BindingOperationInfo pingMe = bindingInfo.getOperation(name);
    assertNotNull(pingMe);
    assertEquals(pingMe.getName(), name);
    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 93 with BindingInfo

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

the class ServiceProcessor method processPort.

private JavaPort processPort(JavaModel model, ServiceInfo si, EndpointInfo port) throws ToolException {
    BindingInfo binding = port.getBinding();
    String portType = binding.getInterface().getName().getLocalPart();
    JavaInterface intf = PortTypeProcessor.getInterface(context, si, binding.getInterface());
    JavaPort jport = new JavaPort(NameUtil.mangleNameToClassName(port.getName().getLocalPart()));
    jport.setPackageName(intf.getPackageName());
    jport.setPortName(port.getName().getLocalPart());
    jport.setBindingAdress(port.getAddress());
    jport.setBindingName(binding.getName().getLocalPart());
    jport.setPortType(portType);
    jport.setInterfaceClass(intf.getName());
    bindingType = getBindingType(binding);
    if (bindingType == null) {
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("BINDING_SPECIFY_ONE_PROTOCOL", LOG, binding.getName());
        throw new ToolException(msg);
    }
    if (isSoapBinding()) {
        SoapBinding spbd = SOAPBindingUtil.getProxy(SoapBinding.class, this.bindingObj);
        jport.setStyle(SOAPBindingUtil.getSoapStyle(spbd.getStyle()));
        jport.setTransURI(spbd.getTransportURI());
    }
    Collection<BindingOperationInfo> operations = binding.getOperations();
    for (BindingOperationInfo bop : operations) {
        processOperation(model, bop, binding);
    }
    jport.setJavaDoc(port.getDocumentation());
    JAXWSBinding bind = port.getExtensor(JAXWSBinding.class);
    if (bind != null) {
        jport.setMethodName(bind.getMethodName());
        jport.setJavaDoc(bind.getMethodJavaDoc());
    }
    return jport;
}
Also used : JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.common.i18n.Message) Message(org.apache.cxf.common.i18n.Message) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) JavaPort(org.apache.cxf.tools.common.model.JavaPort) BindingInfo(org.apache.cxf.service.model.BindingInfo) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding) ToolException(org.apache.cxf.tools.common.ToolException)

Example 94 with BindingInfo

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

the class ServiceWSDLBuilder method buildBinding.

protected void buildBinding(Definition definition, Collection<BindingInfo> bindingInfos, Collection<PortType> portTypes) {
    for (BindingInfo bindingInfo : bindingInfos) {
        final Binding binding = definition.createBinding();
        addDocumentation(binding, bindingInfo.getDocumentation());
        binding.setUndefined(false);
        for (PortType portType : portTypes) {
            if (portType.getQName().equals(bindingInfo.getInterface().getName())) {
                binding.setPortType(portType);
                break;
            }
        }
        binding.setQName(bindingInfo.getName());
        if (!bindingInfo.getName().getNamespaceURI().equals(definition.getTargetNamespace())) {
            addNamespace(bindingInfo.getName().getNamespaceURI(), definition);
        }
        buildBindingOperation(definition, binding, bindingInfo.getOperations());
        addExtensibilityElements(definition, binding, getWSDL11Extensors(bindingInfo));
        definition.addBinding(binding);
    }
}
Also used : Binding(javax.wsdl.Binding) BindingInfo(org.apache.cxf.service.model.BindingInfo) PortType(javax.wsdl.PortType)

Example 95 with BindingInfo

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

the class DocLiteralInInterceptorTest method testUnmarshalSourceDataWrapped.

@Test
public void testUnmarshalSourceDataWrapped() throws Exception {
    XMLStreamReader reader = StaxUtils.createXMLStreamReader(getClass().getResourceAsStream("resources/docLitWrappedReq.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();
    // request to keep the document as wrapped
    m.put(DocLiteralInInterceptor.KEEP_PARAMETERS_WRAPPER, true);
    Exchange exchange = new ExchangeImpl();
    Service service = control.createMock(Service.class);
    exchange.put(Service.class, service);
    EasyMock.expect(service.getDataBinding()).andReturn(new SourceDataBinding()).anyTimes();
    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);
    // wrapped
    OperationInfo operationInfo = new OperationInfo();
    MessageInfo messageInfo = new MessageInfo(operationInfo, Type.INPUT, new QName(NS, "foo"));
    messageInfo.addMessagePart(new MessagePartInfo(new QName(NS, "personId"), null));
    messageInfo.addMessagePart(new MessagePartInfo(new QName(NS, "ssn"), null));
    messageInfo.getMessagePart(0).setConcreteName(new QName(NS, "personId"));
    messageInfo.getMessagePart(1).setConcreteName(new QName(NS, "ssn"));
    operationInfo.setInput("inputName", messageInfo);
    // wrapper
    OperationInfo operationInfoWrapper = new OperationInfo();
    MessageInfo messageInfoWrapper = new MessageInfo(operationInfo, Type.INPUT, new QName(NS, "foo"));
    messageInfoWrapper.addMessagePart(new MessagePartInfo(new QName(NS, "GetPerson"), null));
    messageInfoWrapper.getMessagePart(0).setConcreteName(new QName(NS, "GetPerson"));
    operationInfoWrapper.setInput("inputName", messageInfoWrapper);
    operationInfoWrapper.setUnwrappedOperation(operationInfo);
    ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
    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();
    BindingInfo bindingInfo = new BindingInfo(serviceInfo, "");
    BindingOperationInfo boi = new BindingOperationInfo(bindingInfo, operationInfoWrapper);
    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();
    EasyMock.expect(endpointInfo.getService()).andReturn(serviceInfo).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);
    // we expect a wrapped document
    assertEquals(1, params.size());
    Map<String, String> ns = new HashMap<>();
    ns.put("ns", NS);
    XPathUtils xu = new XPathUtils(ns);
    assertEquals("hello", xu.getValueString("//ns:GetPerson/ns:personId", ((DOMSource) params.get(0)).getNode().getFirstChild()));
    assertEquals("1234", xu.getValueString("//ns:GetPerson/ns:ssn", ((DOMSource) params.get(0)).getNode().getFirstChild()));
}
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) XPathUtils(org.apache.cxf.helpers.XPathUtils) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) 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