Search in sources :

Example 51 with BindingInfo

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

the class WSDLServiceBuilderTest method testBindingInfo.

@Test
public void testBindingInfo() throws Exception {
    setUpBasic();
    assertEquals(1, serviceInfo.getBindings().size());
    BindingInfo bindingInfo = serviceInfo.getBindings().iterator().next();
    assertNotNull(bindingInfo);
    assertEquals(bindingInfo.getInterface().getName().getLocalPart(), "Greeter");
    assertEquals(bindingInfo.getName().getLocalPart(), "Greeter_SOAPBinding");
    assertEquals(bindingInfo.getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
    control.verify();
}
Also used : BindingInfo(org.apache.cxf.service.model.BindingInfo) Test(org.junit.Test)

Example 52 with BindingInfo

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

the class WSDLServiceBuilderTest method testBindingMessageInfo.

@Test
public void testBindingMessageInfo() throws Exception {
    setUpBasic();
    BindingInfo 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)

Example 53 with BindingInfo

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

the class ServiceJavascriptBuilder method begin.

@Override
public void begin(ServiceInfo service) {
    code.append("//\n");
    code.append("// Definitions for service: ").append(service.getName().toString()).append('\n');
    code.append("//\n");
    BindingInfo xml = null;
    // one for each.
    for (BindingInfo bindingInfo : service.getBindings()) {
        // there is a JIRA about the confusion / profusion of URLS here.
        if (SoapBindingConstants.SOAP11_BINDING_ID.equals(bindingInfo.getBindingId()) || SoapBindingConstants.SOAP12_BINDING_ID.equals(bindingInfo.getBindingId()) || SoapBindingFactory.SOAP_11_BINDING.equals(bindingInfo.getBindingId()) || SoapBindingFactory.SOAP_12_BINDING.equals(bindingInfo.getBindingId())) {
            SoapBindingInfo sbi = (SoapBindingInfo) bindingInfo;
            if (WSDLConstants.NS_SOAP11_HTTP_TRANSPORT.equals(sbi.getTransportURI()) || WSDLConstants.NS_SOAP12_HTTP_BINDING.equals(sbi.getTransportURI()) || // we do NOT want a dependency on the local transport.
            "http://cxf.apache.org/transports/local".equals(sbi.getTransportURI())) {
                soapBindingInfo = sbi;
                break;
            }
        } else if (WSDLConstants.NS_BINDING_XML.equals(bindingInfo.getBindingId())) {
            xml = bindingInfo;
        }
    }
    // For now, we use soap if its available, and XML if it isn't.\
    if (soapBindingInfo == null && xml == null) {
        unsupportedConstruct("NO_USABLE_BINDING", service.getName());
    }
    if (soapBindingInfo != null) {
        isRPC = WSDLConstants.RPC.equals(soapBindingInfo.getStyle());
    } else if (xml != null) {
        xmlBindingInfo = xml;
    }
}
Also used : BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo)

Example 54 with BindingInfo

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

the class ReflectionServiceFactoryTest method testServerFactoryBean.

@Test
public void testServerFactoryBean() throws Exception {
    Service service = createService(true);
    assertEquals("test", service.get("test"));
    ServerFactoryBean svrBean = new ServerFactoryBean();
    svrBean.setAddress("http://localhost/Hello");
    svrBean.setServiceFactory(serviceFactory);
    svrBean.setServiceBean(new HelloServiceImpl());
    svrBean.setBus(getBus());
    Map<String, Object> props = new HashMap<>();
    props.put("test", "test");
    serviceFactory.setProperties(props);
    svrBean.setProperties(props);
    Server server = svrBean.create();
    assertNotNull(server);
    Map<QName, Endpoint> eps = service.getEndpoints();
    assertEquals(1, eps.size());
    Endpoint ep = eps.values().iterator().next();
    EndpointInfo endpointInfo = ep.getEndpointInfo();
    assertEquals("test", ep.get("test"));
    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 : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Server(org.apache.cxf.endpoint.Server) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) Service(org.apache.cxf.service.Service) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) Test(org.junit.Test)

Example 55 with BindingInfo

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

the class URIDomainExpressionTest method mockInfoObjects.

private void mockInfoObjects() {
    si = control.createMock(ServiceInfo.class);
    ei = control.createMock(EndpointInfo.class);
    boi = control.createMock(BindingOperationInfo.class);
    bmi = control.createMock(BindingMessageInfo.class);
    bfi = control.createMock(BindingFaultInfo.class);
    InterfaceInfo ii = control.createMock(InterfaceInfo.class);
    EasyMock.expect(si.getTargetNamespace()).andReturn(TARGET_NAMESPACE).anyTimes();
    EasyMock.expect(si.getName()).andReturn(SERVICE_QNAME).anyTimes();
    EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
    EasyMock.expect(ii.getName()).andReturn(INTERFACE_QNAME).anyTimes();
    EasyMock.expect(ei.getName()).andReturn(PORT_QNAME).anyTimes();
    EasyMock.expect(ei.getService()).andReturn(si).anyTimes();
    BindingInfo bi = control.createMock(BindingInfo.class);
    OperationInfo oi = control.createMock(OperationInfo.class);
    EasyMock.expect(boi.getName()).andReturn(OPERATION_QNAME).anyTimes();
    EasyMock.expect(boi.getBinding()).andReturn(bi).anyTimes();
    EasyMock.expect(bi.getName()).andReturn(BINDING_QNAME).anyTimes();
    EasyMock.expect(boi.getOperationInfo()).andReturn(oi).anyTimes();
    EasyMock.expect(oi.getInterface()).andReturn(ii).anyTimes();
    EasyMock.expect(oi.getName()).andReturn(OPERATION_QNAME).anyTimes();
    mi = control.createMock(MessageInfo.class);
    EasyMock.expect(bmi.getMessageInfo()).andReturn(mi).anyTimes();
    EasyMock.expect(mi.getName()).andReturn(MESSAGE_QNAME).anyTimes();
    EasyMock.expect(bmi.getBindingOperation()).andReturn(boi).anyTimes();
    FaultInfo fi = control.createMock(FaultInfo.class);
    bfi = control.createMock(BindingFaultInfo.class);
    EasyMock.expect(bfi.getBindingOperation()).andReturn(boi).anyTimes();
    EasyMock.expect(bfi.getFaultInfo()).andReturn(fi).anyTimes();
    EasyMock.expect(fi.getFaultName()).andReturn(FAULT_QNAME).anyTimes();
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) 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) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

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