Search in sources :

Example 1 with JaxWsSoapBindingConfiguration

use of org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration in project cxf by apache.

the class JaxWsServerFactoryBean method createBindingInfo.

@Override
protected BindingInfo createBindingInfo() {
    JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean) getServiceFactory();
    JaxWsImplementorInfo implInfo = sf.getJaxWsImplementorInfo();
    String jaxBid = implInfo.getBindingType();
    String binding = getBindingId();
    if (binding == null) {
        binding = jaxBid;
        setBindingId(binding);
    }
    if (binding.equals(SOAPBinding.SOAP11HTTP_BINDING) || binding.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING)) {
        binding = "http://schemas.xmlsoap.org/wsdl/soap/";
        setBindingId(binding);
        if (getBindingConfig() == null) {
            setBindingConfig(new JaxWsSoapBindingConfiguration(sf));
        }
    } else if (binding.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING)) {
        binding = SOAPBinding.SOAP12HTTP_BINDING;
        setBindingId(binding);
        if (getBindingConfig() == null) {
            setBindingConfig(new JaxWsSoapBindingConfiguration(sf));
        }
    }
    if (getBindingConfig() instanceof JaxWsSoapBindingConfiguration) {
        JaxWsSoapBindingConfiguration conf = (JaxWsSoapBindingConfiguration) getBindingConfig();
        if (jaxBid.equals(SOAPBinding.SOAP12HTTP_BINDING)) {
            conf.setVersion(Soap12.getInstance());
        }
        if (jaxBid.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING)) {
            conf.setVersion(Soap12.getInstance());
            conf.setMtomEnabled(true);
        }
        if (jaxBid.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING)) {
            conf.setMtomEnabled(true);
        }
        if (transportId != null) {
            conf.setTransportURI(transportId);
        }
        conf.setJaxWsServiceFactoryBean(sf);
    }
    BindingInfo bindingInfo = super.createBindingInfo();
    if (implInfo.isWebServiceProvider()) {
        bindingInfo.getService().setProperty("soap.force.doclit.bare", Boolean.TRUE);
        if (this.getServiceFactory().isPopulateFromClass()) {
            for (EndpointInfo ei : bindingInfo.getService().getEndpoints()) {
                ei.setProperty("soap.no.validate.parts", Boolean.TRUE);
            }
            // Provider, but no wsdl.  Synthetic ops
            for (BindingOperationInfo op : bindingInfo.getOperations()) {
                op.setProperty("operation.is.synthetic", Boolean.TRUE);
                op.getOperationInfo().setProperty("operation.is.synthetic", Boolean.TRUE);
            }
        }
    }
    return bindingInfo;
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) JaxWsImplementorInfo(org.apache.cxf.jaxws.support.JaxWsImplementorInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BindingInfo(org.apache.cxf.service.model.BindingInfo) JaxWsSoapBindingConfiguration(org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration)

Example 2 with JaxWsSoapBindingConfiguration

use of org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration in project cxf by apache.

the class ServiceImpl method createEndpointInfo.

private EndpointInfo createEndpointInfo(AbstractServiceFactoryBean serviceFactory, QName portName, PortInfoImpl portInfo) throws BusException {
    EndpointInfo ei = null;
    String address = portInfo.getAddress();
    String bindingID = BindingID.getBindingID(portInfo.getBindingID());
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    try {
        // the bindingId might be the transportId, just attempt to
        // load it to force the factory to load
        dfm.getDestinationFactory(bindingID);
    } catch (BusException ex) {
    // ignore
    }
    DestinationFactory df = dfm.getDestinationFactoryForUri(address);
    String transportId = null;
    if (df != null && df.getTransportIds() != null && !df.getTransportIds().isEmpty()) {
        transportId = df.getTransportIds().get(0);
    } else {
        transportId = bindingID;
    }
    Object config = null;
    if (serviceFactory instanceof JaxWsServiceFactoryBean) {
        config = new JaxWsSoapBindingConfiguration((JaxWsServiceFactoryBean) serviceFactory);
    }
    BindingInfo bindingInfo = bus.getExtension(BindingFactoryManager.class).getBindingFactory(bindingID).createBindingInfo(serviceFactory.getService(), bindingID, config);
    Service service = serviceFactory.getService();
    service.getServiceInfos().get(0).addBinding(bindingInfo);
    ei = new EndpointInfo(service.getServiceInfos().get(0), transportId);
    ei.setName(portName);
    ei.setAddress(address);
    ei.setBinding(bindingInfo);
    service.getServiceInfos().get(0).addEndpoint(ei);
    return ei;
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) DestinationFactory(org.apache.cxf.transport.DestinationFactory) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) BindingInfo(org.apache.cxf.service.model.BindingInfo) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) JaxWsSoapBindingConfiguration(org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration) BusException(org.apache.cxf.BusException)

Example 3 with JaxWsSoapBindingConfiguration

use of org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration in project cxf by apache.

the class HeaderTest method testInvocation.

@Test
public void testInvocation() throws Exception {
    JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    Bus bus = getBus();
    bean.setBus(bus);
    bean.setServiceClass(TestHeaderImpl.class);
    Service service = bean.create();
    OperationInfo op = service.getServiceInfos().get(0).getInterface().getOperation(new QName(service.getName().getNamespaceURI(), "testHeader5"));
    assertNotNull(op);
    List<MessagePartInfo> parts = op.getInput().getMessageParts();
    assertEquals(1, parts.size());
    MessagePartInfo part = parts.get(0);
    assertNotNull(part.getTypeClass());
    assertEquals(TestHeader5.class, part.getTypeClass());
    parts = op.getOutput().getMessageParts();
    assertEquals(2, parts.size());
    part = parts.get(1);
    assertNotNull(part.getTypeClass());
    assertEquals(TestHeader5ResponseBody.class, part.getTypeClass());
    part = parts.get(0);
    assertNotNull(part.getTypeClass());
    assertEquals(TestHeader5.class, part.getTypeClass());
    // part = parts.get(1);
    // assertNotNull(part.getTypeClass());
    ServerFactoryBean svr = new ServerFactoryBean();
    svr.setBus(bus);
    svr.setServiceFactory(bean);
    svr.setServiceBean(new TestHeaderImpl());
    svr.setAddress("http://localhost:9104/SoapHeaderContext/SoapHeaderPort");
    svr.setBindingConfig(new JaxWsSoapBindingConfiguration(bean));
    svr.create();
    Node response = invoke("http://localhost:9104/SoapHeaderContext/SoapHeaderPort", LocalTransportFactory.TRANSPORT_ID, "testHeader5.xml");
    assertNotNull(response);
    assertNoFault(response);
    addNamespace("t", "http://apache.org/header_test/types");
    assertValid("//s:Header/t:testHeader5", response);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) Bus(org.apache.cxf.Bus) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) QName(javax.xml.namespace.QName) Node(org.w3c.dom.Node) Service(org.apache.cxf.service.Service) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) JaxWsSoapBindingConfiguration(org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) TestHeaderImpl(org.apache.header_test.TestHeaderImpl) Test(org.junit.Test)

Aggregations

JaxWsSoapBindingConfiguration (org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration)3 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)3 Service (org.apache.cxf.service.Service)2 BindingInfo (org.apache.cxf.service.model.BindingInfo)2 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)2 WebService (javax.jws.WebService)1 QName (javax.xml.namespace.QName)1 Bus (org.apache.cxf.Bus)1 BusException (org.apache.cxf.BusException)1 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)1 JaxWsImplementorInfo (org.apache.cxf.jaxws.support.JaxWsImplementorInfo)1 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)1 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)1 OperationInfo (org.apache.cxf.service.model.OperationInfo)1 DestinationFactory (org.apache.cxf.transport.DestinationFactory)1 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)1 TestHeaderImpl (org.apache.header_test.TestHeaderImpl)1 Test (org.junit.Test)1 Node (org.w3c.dom.Node)1