Search in sources :

Example 16 with SoapBindingInfo

use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.

the class MAPAggregatorTest method testGetReplyToUsingBaseAddress.

@Test
public void testGetReplyToUsingBaseAddress() throws Exception {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);
    final String localReplyTo = "/SoapContext/decoupled";
    final String decoupledEndpointBase = "http://localhost:8181/cxf";
    final String replyTo = decoupledEndpointBase + localReplyTo;
    ServiceInfo s = new ServiceInfo();
    Service svc = new ServiceImpl(s);
    EndpointInfo ei = new EndpointInfo();
    InterfaceInfo ii = s.createInterface(new QName("FooInterface"));
    s.setInterface(ii);
    ii.addOperation(new QName("fooOp"));
    SoapBindingInfo b = new SoapBindingInfo(s, "http://schemas.xmlsoap.org/soap/", Soap11.getInstance());
    b.setTransportURI("http://schemas.xmlsoap.org/soap/http");
    ei.setBinding(b);
    ei.setAddress("http://nowhere.com/bar/foo");
    ei.setName(new QName("http://nowhere.com/port", "foo"));
    Bus bus = new ExtensionManagerBus();
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    DestinationFactory df = control.createMock(DestinationFactory.class);
    Destination d = control.createMock(Destination.class);
    bus.setExtension(dfm, DestinationFactoryManager.class);
    EasyMock.expect(dfm.getDestinationFactoryForUri(localReplyTo)).andReturn(df);
    EasyMock.expect(df.getDestination(EasyMock.anyObject(EndpointInfo.class), EasyMock.anyObject(Bus.class))).andReturn(d);
    EasyMock.expect(d.getAddress()).andReturn(EndpointReferenceUtils.getEndpointReference(localReplyTo));
    Endpoint ep = new EndpointImpl(bus, svc, ei);
    exchange.put(Endpoint.class, ep);
    exchange.put(Bus.class, bus);
    exchange.setOutMessage(message);
    setUpMessageProperty(message, REQUESTOR_ROLE, Boolean.TRUE);
    message.getContextualProperty(WSAContextUtils.REPLYTO_PROPERTY);
    message.put(WSAContextUtils.REPLYTO_PROPERTY, localReplyTo);
    message.put(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY, decoupledEndpointBase);
    AddressingProperties maps = new AddressingProperties();
    AttributedURIType id = ContextUtils.getAttributedURI("urn:uuid:12345");
    maps.setMessageID(id);
    maps.setAction(ContextUtils.getAttributedURI(""));
    setUpMessageProperty(message, CLIENT_ADDRESSING_PROPERTIES, maps);
    control.replay();
    aggregator.mediate(message, false);
    AddressingProperties props = (AddressingProperties) message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND);
    assertEquals(replyTo, props.getReplyTo().getAddress().getValue());
    control.verify();
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) DestinationFactory(org.apache.cxf.transport.DestinationFactory) Destination(org.apache.cxf.transport.Destination) Message(org.apache.cxf.message.Message) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) ServiceImpl(org.apache.cxf.service.ServiceImpl) QName(javax.xml.namespace.QName) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Service(org.apache.cxf.service.Service) Exchange(org.apache.cxf.message.Exchange) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) MessageImpl(org.apache.cxf.message.MessageImpl) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 17 with SoapBindingInfo

use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.

the class ManagedRMManagerTest method createTestEndpoint.

private Endpoint createTestEndpoint() throws Exception {
    ServiceInfo svci = new ServiceInfo();
    svci.setName(new QName(TEST_URI, "testService"));
    Service svc = new ServiceImpl(svci);
    SoapBindingInfo binding = new SoapBindingInfo(svci, WSDLConstants.NS_SOAP11);
    binding.setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress(TEST_URI);
    ei.setName(new QName(TEST_URI, "testPort"));
    ei.setBinding(binding);
    ei.setService(svci);
    return new EndpointImpl(bus, svc, ei);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) QName(javax.xml.namespace.QName) ServiceImpl(org.apache.cxf.service.ServiceImpl) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) Service(org.apache.cxf.service.Service)

Example 18 with SoapBindingInfo

use of org.apache.cxf.binding.soap.model.SoapBindingInfo 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 19 with SoapBindingInfo

use of org.apache.cxf.binding.soap.model.SoapBindingInfo 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 20 with SoapBindingInfo

use of org.apache.cxf.binding.soap.model.SoapBindingInfo in project cxf by apache.

the class SoapBindingFactory method createBindingInfo.

public BindingInfo createBindingInfo(ServiceInfo si, String bindingid, Object conf) {
    SoapBindingConfiguration config;
    if (conf instanceof SoapBindingConfiguration) {
        config = (SoapBindingConfiguration) conf;
    } else {
        config = new SoapBindingConfiguration();
    }
    if (WSDLConstants.NS_SOAP12.equals(bindingid) || WSDLConstants.NS_SOAP12_HTTP_BINDING.equals(bindingid)) {
        config.setVersion(Soap12.getInstance());
        config.setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    }
    SoapBindingInfo info = new SoapBindingInfo(si, bindingid, config.getVersion());
    info.setName(config.getBindingName(si));
    info.setStyle(config.getStyle());
    info.setTransportURI(config.getTransportURI());
    if (config.isMtomEnabled()) {
        info.setProperty(Message.MTOM_ENABLED, Boolean.TRUE);
    }
    for (OperationInfo op : si.getInterface().getOperations()) {
        SoapOperationInfo sop = new SoapOperationInfo();
        sop.setAction(config.getSoapAction(op));
        sop.setStyle(config.getStyle(op));
        BindingOperationInfo bop = info.buildOperation(op.getName(), op.getInputName(), op.getOutputName());
        bop.addExtensor(sop);
        info.addOperation(bop);
        BindingMessageInfo bInput = bop.getInput();
        if (bInput != null) {
            MessageInfo input = null;
            BindingMessageInfo unwrappedMsg = bInput;
            if (bop.isUnwrappedCapable()) {
                input = bop.getOperationInfo().getUnwrappedOperation().getInput();
                unwrappedMsg = bop.getUnwrappedOperation().getInput();
            } else {
                input = bop.getOperationInfo().getInput();
            }
            setupHeaders(bop, bInput, unwrappedMsg, input, config);
        }
        BindingMessageInfo bOutput = bop.getOutput();
        if (bOutput != null) {
            MessageInfo output = null;
            BindingMessageInfo unwrappedMsg = bOutput;
            if (bop.isUnwrappedCapable()) {
                output = bop.getOperationInfo().getUnwrappedOperation().getOutput();
                unwrappedMsg = bop.getUnwrappedOperation().getOutput();
            } else {
                output = bop.getOperationInfo().getOutput();
            }
            setupHeaders(bop, bOutput, unwrappedMsg, output, config);
        }
    }
    try {
        createSoapBinding(info);
    } catch (WSDLException e) {
        e.printStackTrace();
    }
    return info;
}
Also used : 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) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) WSDLException(javax.wsdl.WSDLException) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

Aggregations

SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)23 QName (javax.xml.namespace.QName)11 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)11 BindingInfo (org.apache.cxf.service.model.BindingInfo)10 Endpoint (org.apache.cxf.endpoint.Endpoint)9 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)9 Test (org.junit.Test)9 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)8 Service (org.apache.cxf.service.Service)8 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)5 Bus (org.apache.cxf.Bus)4 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)4 Definition (javax.wsdl.Definition)3 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)3 SoapVersion (org.apache.cxf.binding.soap.SoapVersion)3 SoapBodyInfo (org.apache.cxf.binding.soap.model.SoapBodyInfo)3 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)3 BusException (org.apache.cxf.BusException)2 Binding (org.apache.cxf.binding.Binding)2 SoapBinding (org.apache.cxf.binding.soap.SoapBinding)2