Exemple #1
0
 public static void main(String[] args) {
   JaxWsServerFactoryBean fac = new JaxWsServerFactoryBean();
   fac.setServiceClass(AccountManager.class);
   fac.setServiceBean(new AccountManagerImpl());
   fac.setAddress("http://localhost:9000/services/am");
   fac.create();
 }
  public static Server createServer(
      String port,
      Class<?> serviceInterface,
      Object serviceImpl,
      SchemaValidationType type,
      Feature... features)
      throws IOException {
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(serviceImpl.getClass());

    if (features != null) {
      svrFactory.getFeatures().addAll(Arrays.asList(features));
    }

    if (type != null) {
      Map<String, Object> properties = new HashMap<String, Object>();
      properties.put(Message.SCHEMA_VALIDATION_ENABLED, type);
      svrFactory.setProperties(properties);
    }

    svrFactory.setAddress(getAddress(port, serviceInterface));
    svrFactory.setServiceBean(serviceImpl);
    Server server = svrFactory.create();
    serverList.add(server);
    return server;
  }
  private Service createService() {
    // Create the Service
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceBean(new EchoImpl());
    factory.setAddress("local://Echo");
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    Server server = factory.create();

    Service service = server.getEndpoint().getService();
    service.getInInterceptors().add(new LoggingInInterceptor());
    service.getOutInterceptors().add(new LoggingOutInterceptor());

    return service;
  }
 @Override
 public void loadBus(ServletConfig servletConfig) {
   super.loadBus(servletConfig);
   BimServer bimServer = (BimServer) servletConfig.getServletContext().getAttribute("bimserver");
   Bus bus = getBus();
   BusFactory.setDefaultBus(bus);
   JaxWsServerFactoryBean serverFactoryBean = new JaxWsServerFactoryBean();
   Map<String, Object> properties = new HashMap<String, Object>();
   properties.put("mtom-enabled", Boolean.TRUE);
   serverFactoryBean.setProperties(properties);
   serverFactoryBean.setServiceClass(ServiceInterface.class);
   serverFactoryBean.setInvoker(new CustomInvoker(bimServer.getServiceFactory()));
   serverFactoryBean.setAddress("/");
   serverFactoryBean.setTransportId("http://schemas.xmlsoap.org/soap/http");
   serverFactoryBean.create();
 }
  @Test
  public void testServerFactory() {
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();

    assert bus != null;
    sf.setServiceBean(new GreeterImpl());
    sf.setAddress("http://localhost:" + PORT + "/test");
    sf.setStart(false);

    Configurer c = getBus().getExtension(Configurer.class);
    c.configureBean("server", sf);

    Server server = sf.create();

    Endpoint endpoint = server.getEndpoint();
    checkAddressInterceptors(endpoint.getInInterceptors());
  }
 @BeforeClass
 public static void startServer() throws Exception {
   // start a simple front service
   JaxWsServiceFactoryBean svrFBean = new JaxWsServiceFactoryBean();
   svrFBean.setServiceClass(EchoService.class);
   JaxWsServerFactoryBean svrBean = new JaxWsServerFactoryBean(svrFBean);
   svrBean.setAddress(SIMPLE_SERVER_ADDRESS);
   svrBean.setServiceClass(EchoService.class);
   svrBean.setServiceBean(new EchoServiceSessionImpl());
   // make the Jetty server support sessions
   Bus bus = BusFactory.newInstance().createBus();
   JettyHTTPServerEngineFactory jettyFactory =
       bus.getExtension(JettyHTTPServerEngineFactory.class);
   jettyFactory.createJettyHTTPServerEngine(PORT, "http").setSessionSupport(true);
   svrBean.setBus(bus);
   svrBean.create();
 }
Exemple #7
0
  @Test(expected = HelloException.class)
  public void testJaxws() throws Exception {
    JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
    sfbean.setServiceClass(ExceptionService.class);
    setupAegis(sfbean);
    sfbean.setAddress("local://ExceptionService4");
    Server server = sfbean.create();
    Service service = server.getEndpoint().getService();
    service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));

    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setAddress("local://ExceptionService4");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());
    ExceptionService clientInterface = proxyFac.create(ExceptionService.class);

    clientInterface.sayHiWithException();
  }
  private void subTestServerStartup() throws Exception {
    final SeekBookInBasementHandler businessHandler =
        new SeekBookInBasementHandler(responseLocation, "classpath:" + wsdlLocation);
    final ServiceProviderHandler implementor =
        new ServiceProviderHandler(errorTransfer, messageTransfer, businessHandler, operation);

    final JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();

    factory.setServiceName(SERVICE_NAME);
    factory.setEndpointName(PORT_NAME);
    factory.setWsdlLocation(wsdlLocation);
    factory.setServiceBean(implementor);

    CallContext.setupServerFactory(factory);
    server = factory.create();
    sleep(1);
    checkError(false);
  }
Exemple #9
0
  @Test(expected = HelloException.class)
  public void testJaxwsNoXfireCompat() throws Exception {
    JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
    sfbean.setServiceClass(ExceptionService.class);
    sfbean.setDataBinding(new AegisDatabinding());
    sfbean.getServiceFactory().setDataBinding(sfbean.getDataBinding());
    sfbean.setAddress("local://ExceptionServiceJaxWs");
    Server server = sfbean.create();
    Service service = server.getEndpoint().getService();
    service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));

    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setAddress("local://ExceptionServiceJaxWs");
    proxyFac.setServiceClass(ExceptionService.class);
    proxyFac.setBus(getBus());
    proxyFac.getClientFactoryBean().getServiceFactory().setDataBinding(new AegisDatabinding());
    ExceptionService clientInterface = (ExceptionService) proxyFac.create();

    clientInterface.sayHiWithException();
  }
Exemple #10
0
  @Test(expected = HelloException.class)
  @Ignore("Not working yet due to namespace things")
  public void testJaxwsServerSimpleClient() throws Exception {
    JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
    sfbean.setServiceClass(ExceptionService.class);
    sfbean.setDataBinding(new AegisDatabinding());
    sfbean.setAddress("local://ExceptionServiceJaxWs1");
    Server server = sfbean.create();
    Service service = server.getEndpoint().getService();
    service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));

    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    proxyFac.setAddress("local://ExceptionServiceJaxWs1");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());

    ExceptionService clientInterface = proxyFac.create(ExceptionService.class);

    clientInterface.sayHiWithException();
  }
  @org.junit.Test
  public void testAnnotations() throws Exception {
    Bus bus = BusFactory.getDefaultBus();
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setBus(bus);
    factory.setServiceBean(new TestImpl());
    factory.setStart(false);
    List<String> tp =
        Arrays.asList(
            "http://schemas.xmlsoap.org/soap/http",
            "http://schemas.xmlsoap.org/wsdl/http/",
            "http://schemas.xmlsoap.org/wsdl/soap/http",
            "http://www.w3.org/2003/05/soap/bindings/HTTP/",
            "http://cxf.apache.org/transports/http/configuration",
            "http://cxf.apache.org/bindings/xformat");

    LocalTransportFactory f = new LocalTransportFactory(bus);
    f.getUriPrefixes().add("http");
    f.setTransportIds(tp);
    f.setBus(bus);
    f.register();

    Server s = factory.create();

    try {
      ServiceWSDLBuilder builder =
          new ServiceWSDLBuilder(bus, s.getEndpoint().getService().getServiceInfos());
      Definition def = builder.build();
      WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
      def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
      Element wsdl = wsdlWriter.getDocument(def).getDocumentElement();

      Map<String, String> ns = new HashMap<String, String>();
      ns.put("wsdl", WSDLConstants.NS_WSDL11);
      ns.put(
          "wsu",
          "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
      ns.put("wsp", Constants.URI_POLICY_13_NS);
      XPathUtils xpu = new XPathUtils(ns);
      // org.apache.cxf.helpers.XMLUtils.printDOM(wsdl);
      check(xpu, wsdl, "/wsdl:definitions/wsdl:service/wsdl:port", "TestImplPortPortPolicy");
      check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/", "TestInterfacePortTypePolicy");
      check(
          xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/", "echoIntPortTypeOpPolicy");
      check(
          xpu,
          wsdl,
          "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:input",
          "echoIntPortTypeOpInputPolicy");
      check(
          xpu,
          wsdl,
          "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:output",
          "echoIntPortTypeOpOutputPolicy");
      check(
          xpu, wsdl, "/wsdl:definitions/wsdl:binding/", "TestImplServiceSoapBindingBindingPolicy");
      check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/", "echoIntBindingOpPolicy");
      check(
          xpu,
          wsdl,
          "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:input",
          "echoIntBindingOpInputPolicy");
      check(
          xpu,
          wsdl,
          "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:output",
          "echoIntBindingOpOutputPolicy");
      check(xpu, wsdl, "/wsdl:definitions/wsdl:service/", "TestImplServiceServicePolicy");

      EndpointPolicy policy =
          bus.getExtension(PolicyEngine.class)
              .getServerEndpointPolicy(s.getEndpoint().getEndpointInfo(), null);
      assertNotNull(policy);
      assertEquals(1, policy.getChosenAlternative().size());
    } finally {
      bus.shutdown(true);
    }
  }