Search in sources :

Example 71 with BindingInfo

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

the class ServiceModelUtilTest method testGetSchema.

@Test
public void testGetSchema() throws Exception {
    BindingInfo bindingInfo = serviceInfo.getBindings().iterator().next();
    QName name = new QName(serviceInfo.getName().getNamespaceURI(), "inHeader");
    BindingOperationInfo inHeader = bindingInfo.getOperation(name);
    BindingMessageInfo input = inHeader.getInput();
    assertNotNull(input);
    assertEquals(input.getMessageInfo().getName().getLocalPart(), "inHeaderRequest");
    assertEquals(input.getMessageInfo().getName().getNamespaceURI(), "http://org.apache.cxf/headers");
    assertEquals(input.getMessageInfo().getMessageParts().size(), 2);
    assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement());
    assertEquals(input.getMessageInfo().getMessageParts().get(0).getElementQName().getLocalPart(), "inHeader");
    assertEquals(input.getMessageInfo().getMessageParts().get(0).getElementQName().getNamespaceURI(), "http://org.apache.cxf/headers");
    assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement());
    assertEquals(input.getMessageInfo().getMessageParts().get(1).getElementQName().getLocalPart(), "passenger");
    assertEquals(input.getMessageInfo().getMessageParts().get(1).getElementQName().getNamespaceURI(), "http://mycompany.example.com/employees");
    assertTrue(input.getMessageInfo().getMessageParts().get(1).isElement());
    MessagePartInfo messagePartInfo = input.getMessageInfo().getMessageParts().get(0);
    SchemaInfo schemaInfo = ServiceModelUtil.getSchema(serviceInfo, messagePartInfo);
    assertEquals(schemaInfo.getNamespaceURI(), "http://org.apache.cxf/headers");
    messagePartInfo = input.getMessageInfo().getMessageParts().get(1);
    schemaInfo = ServiceModelUtil.getSchema(serviceInfo, messagePartInfo);
    assertEquals(schemaInfo.getNamespaceURI(), "http://mycompany.example.com/employees");
}
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) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) SchemaInfo(org.apache.cxf.service.model.SchemaInfo) Test(org.junit.Test)

Example 72 with BindingInfo

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

the class SoapBindingFactoryTest method testNoBodyParts.

@Test
public void testNoBodyParts() throws Exception {
    Definition d = createDefinition("/wsdl_soap/no_body_parts.wsdl");
    Bus bus = getMockBus();
    BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.NS_SOAP11, bus);
    bus.getExtension(BindingFactoryManager.class);
    expectLastCall().andReturn(bfm).anyTimes();
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
    control.replay();
    WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
    ServiceInfo serviceInfo = builder.buildServices(d, new QName("urn:org:apache:cxf:no_body_parts/wsdl", "NoBodyParts")).get(0);
    BindingInfo bi = serviceInfo.getBindings().iterator().next();
    assertTrue(bi instanceof SoapBindingInfo);
    SoapBindingInfo sbi = (SoapBindingInfo) bi;
    assertEquals("document", sbi.getStyle());
    assertTrue(WSDLConstants.NS_SOAP11_HTTP_TRANSPORT.equalsIgnoreCase(sbi.getTransportURI()));
    assertTrue(sbi.getSoapVersion() instanceof Soap11);
    BindingOperationInfo boi = sbi.getOperation(new QName("urn:org:apache:cxf:no_body_parts/wsdl", "operation1"));
    assertNotNull(boi);
    SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
    assertNotNull(sboi);
    assertNull(sboi.getStyle());
    assertEquals("", sboi.getAction());
    BindingMessageInfo input = boi.getInput();
    SoapBodyInfo bodyInfo = input.getExtensor(SoapBodyInfo.class);
    assertNull(bodyInfo.getUse());
    List<MessagePartInfo> parts = bodyInfo.getParts();
    assertNotNull(parts);
    assertEquals(0, parts.size());
}
Also used : Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) SoapBodyInfo(org.apache.cxf.binding.soap.model.SoapBodyInfo) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) Test(org.junit.Test)

Example 73 with BindingInfo

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

the class SoapBindingFactoryTest method testSoap12Factory.

@Test
public void testSoap12Factory() throws Exception {
    Definition d = createDefinition("/wsdl_soap/hello_world_soap12.wsdl");
    Bus bus = getMockBus();
    BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.NS_SOAP12, bus);
    expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
    control.replay();
    WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
    ServiceInfo serviceInfo = builder.buildServices(d, new QName("http://apache.org/hello_world_soap12_http", "SOAPService")).get(0);
    BindingInfo bi = serviceInfo.getBindings().iterator().next();
    assertTrue(bi instanceof SoapBindingInfo);
    SoapBindingInfo sbi = (SoapBindingInfo) bi;
    assertEquals("document", sbi.getStyle());
    assertEquals(WSDLConstants.NS_SOAP_HTTP_TRANSPORT, sbi.getTransportURI());
    assertTrue(sbi.getSoapVersion() instanceof Soap12);
    BindingOperationInfo boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap12_http", "sayHi"));
    SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
    assertNotNull(sboi);
    assertEquals("document", sboi.getStyle());
    assertEquals("sayHiAction", sboi.getAction());
    BindingMessageInfo input = boi.getInput();
    SoapBodyInfo bodyInfo = input.getExtensor(SoapBodyInfo.class);
    assertEquals("literal", bodyInfo.getUse());
    List<MessagePartInfo> parts = bodyInfo.getParts();
    assertNotNull(parts);
    assertEquals(1, parts.size());
    boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap12_http", "pingMe"));
    sboi = boi.getExtensor(SoapOperationInfo.class);
    assertNotNull(sboi);
    assertEquals("document", sboi.getStyle());
    assertEquals("", sboi.getAction());
    Collection<BindingFaultInfo> faults = boi.getFaults();
    assertEquals(1, faults.size());
    BindingFaultInfo faultInfo = boi.getFault(new QName("http://apache.org/hello_world_soap12_http", "pingMeFault"));
    assertNotNull(faultInfo);
}
Also used : Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) SoapBodyInfo(org.apache.cxf.binding.soap.model.SoapBodyInfo) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) Test(org.junit.Test)

Example 74 with BindingInfo

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

the class MustUnderstandInterceptorTest method testHandleMessageWithSoapHeader12Param.

@Test
public void testHandleMessageWithSoapHeader12Param() throws Exception {
    prepareSoapMessage("test-soap-12-header.xml");
    dsi.getUnderstoodHeaders().add(RESERVATION);
    ServiceInfo serviceInfo = getMockedServiceModel(getClass().getResource("test-soap-12-header.wsdl").toString());
    BindingInfo binding = serviceInfo.getBinding(new QName("http://org.apache.cxf/headers", "headerTesterSOAPBinding"));
    BindingOperationInfo bop = binding.getOperation(new QName("http://org.apache.cxf/headers", "inHeader"));
    soapMessage.getExchange().put(BindingOperationInfo.class, bop);
    soapMessage.getInterceptorChain().doIntercept(soapMessage);
    assertTrue("DummaySoapInterceptor getRoles has been called!", dsi.isCalledGetRoles());
    assertTrue("DummaySoapInterceptor getUnderstood has been called!", dsi.isCalledGetUnderstood());
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo) Test(org.junit.Test)

Example 75 with BindingInfo

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

the class DispatchImpl method addInvokeOperation.

private void addInvokeOperation(boolean oneWay) {
    String name = oneWay ? INVOKE_ONEWAY_NAME : INVOKE_NAME;
    ServiceInfo info = client.getEndpoint().getEndpointInfo().getService();
    OperationInfo opInfo = info.getInterface().addOperation(oneWay ? INVOKE_ONEWAY_QNAME : INVOKE_QNAME);
    MessageInfo mInfo = opInfo.createMessage(new QName(DISPATCH_NS, name + "Request"), Type.INPUT);
    opInfo.setInput(name + "Request", mInfo);
    MessagePartInfo mpi = mInfo.addMessagePart("parameters");
    if (context == null) {
        mpi.setTypeClass(cl);
    }
    mpi.setElement(true);
    if (!oneWay) {
        mInfo = opInfo.createMessage(new QName(DISPATCH_NS, name + "Response"), Type.OUTPUT);
        opInfo.setOutput(name + "Response", mInfo);
        mpi = mInfo.addMessagePart("parameters");
        mpi.setElement(true);
        if (context == null) {
            mpi.setTypeClass(cl);
        }
    }
    for (BindingInfo bind : client.getEndpoint().getEndpointInfo().getService().getBindings()) {
        BindingOperationInfo bo = new BindingOperationInfo(bind, opInfo);
        bind.addOperation(bo);
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo)

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