public Conduit getConduit(EndpointInfo ei, EndpointReferenceType target, Bus bus)
     throws IOException {
   String address = target == null ? ei.getAddress() : target.getAddress().getValue();
   BindingInfo bi = ei.getBinding();
   String transId = ei.getTransportId();
   if (bi instanceof SoapBindingInfo) {
     transId = ((SoapBindingInfo) bi).getTransportURI();
     if (transId == null) {
       transId = ei.getTransportId();
     }
   }
   ConduitInitiator conduitInit;
   try {
     ConduitInitiatorManager mgr = bus.getExtension(ConduitInitiatorManager.class);
     if (StringUtils.isEmpty(address)
         || address.startsWith("http")
         || address.startsWith("jms")
         || address.startsWith("soap.udp")) {
       conduitInit = mgr.getConduitInitiator(mapTransportURI(transId, address));
     } else {
       conduitInit = mgr.getConduitInitiatorForUri(address);
     }
     if (conduitInit == null) {
       throw new RuntimeException(String.format(CANNOT_GET_CONDUIT_ERROR, address, transId));
     }
     return conduitInit.getConduit(ei, target, bus);
   } catch (BusException e) {
     throw new RuntimeException(String.format(CANNOT_GET_CONDUIT_ERROR, address, transId));
   }
 }
  @Before
  public void initialize() throws Exception {
    if (mep == NO_RUN) {
      return;
    }
    final Bus bus = BusFactory.getDefaultBus();
    final LocalTransportFactory localTransport = new LocalTransportFactory();
    final DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/jms", localTransport);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
    dfm.registerDestinationFactory("http://cxf.apache.org/bindings/xformat", localTransport);
    dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", localTransport);

    final ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
    extension.registerConduitInitiator("http://cxf.apache.org/transports/local", localTransport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/jms", localTransport);
    extension.registerConduitInitiator("http://cxf.apache.org/bindings/xformat", localTransport);

    final WSDLServiceFactory wsdlSvcFactory =
        new WSDLServiceFactory(CXFBusFactory.getThreadDefaultBus(), wsdlLocation, SERVICE_NAME);
    final org.apache.cxf.service.Service cxfService = wsdlSvcFactory.create();
    final ServiceInfo si = findServiceByName(cxfService, SERVICE_NAME);
    if (si == null) {
      throw new RuntimeException("WSDL does not contain service " + SERVICE_NAME);
    }
    final EndpointInfo ei = findEndpoint(si, PORT_NAME);
    if (ei == null) {
      throw new RuntimeException("WSDL does not contain port " + PORT_NAME);
    }
    endpointInfo = ei;

    callbackMap.put(
        "seekBookInBasementResponse", new SeekBookInBasementResponseCallback(messageTransfer));
    callbackMap.put(
        "seekBookInBasementFault", new SeekBookInBasementFaultCallback(messageTransfer));
  }
Example #3
0
  protected void doInitialise() throws InitialisationException {
    ApplicationContext context =
        (ApplicationContext)
            muleContext.getRegistry().lookupObject(SpringRegistry.SPRING_APPLICATION_CONTEXT);

    if (configurationLocation != null) {
      bus = new SpringBusFactory(context).createBus(configurationLocation, true);
    } else {
      bus = new SpringBusFactory(context).createBus((String) null, true);
    }

    if (!initializeStaticBusInstance) {
      BusFactory.setDefaultBus(null);
    }

    MuleUniversalTransport transport = new MuleUniversalTransport(this);
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", transport);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", transport);
    dfm.registerDestinationFactory(
        "http://cxf.apache.org/transports/http/configuration", transport);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/http/", transport);
    dfm.registerDestinationFactory("http://www.w3.org/2003/05/soap/bindings/HTTP/", transport);
    dfm.registerDestinationFactory(MuleUniversalTransport.TRANSPORT_ID, transport);

    ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
    try {
      // Force the HTTP transport to load if available, otherwise it could
      // overwrite our namespaces later
      extension.getConduitInitiator("http://schemas.xmlsoap.org/soap/http");
    } catch (BusException e1) {
      // If unavailable eat exception and continue
    }
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", transport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", transport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http/", transport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/http", transport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/http/", transport);
    extension.registerConduitInitiator("http://www.w3.org/2003/05/soap/bindings/HTTP/", transport);
    extension.registerConduitInitiator(
        "http://cxf.apache.org/transports/http/configuration", transport);
    extension.registerConduitInitiator("http://cxf.apache.org/bindings/xformat", transport);
    extension.registerConduitInitiator(MuleUniversalTransport.TRANSPORT_ID, transport);

    // Registers the listener
    try {
      muleContext.registerListener(this);
    } catch (Exception e) {
      throw new InitialisationException(e, this);
    }
  }