//	@Test
  public void batchInsert() throws Exception {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(ClassInfoBizService.class);
    factory.setAddress("http://127.0.0.1:8088/xlimsws/ClassInfoBizService");
    ClassInfoBizService service = (ClassInfoBizService) factory.create();

    for (int i = 1; i <= 5; i++) {
      ClassInfo c = new ClassInfo();
      c.setBh("2015秋");
      c.setBjmc("2015秋第" + i + "班");
      c.setXz(3.5);
      c.setXxzx("学习中心");
      c.setXx("国开实验(广州)学校");
      c.setCrps("junit");
      c.setCrss("junit");

      c = service.save(c);
      System.out.println(
          "success : "
              + c.isSuccessful()
              + ","
              + c.getMessages().size()
              + "\n"
              + c.getStrMessage());
      System.out.println("atid : " + c.getAtid());
      System.out.println("===============batchInsert===============");
    }
  }
Example #2
0
  @org.junit.Test
  public void testRetrieveWSMEX() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = IssueUnitTest.class.getResource("cxf-client.xml");

    Bus bus = bf.createBus(busFile.toString());
    SpringBusFactory.setDefaultBus(bus);
    SpringBusFactory.setThreadDefaultBus(bus);

    // Get Metadata
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setBindingId(SoapBindingConstants.SOAP11_BINDING_ID);
    proxyFac.setAddress("https://localhost:" + STSPORT + "/SecurityTokenService/Transport/mex");
    MetadataExchange exc = proxyFac.create(MetadataExchange.class);
    Metadata metadata = exc.get2004();

    // Parse response (as per the STSClient)
    Definition definition = null;
    // Parse the MetadataSections into WSDL definition + associated schemas
    for (MetadataSection s : metadata.getMetadataSection()) {
      if ("http://schemas.xmlsoap.org/wsdl/".equals(s.getDialect())) {
        definition = bus.getExtension(WSDLManager.class).getDefinition((Element) s.getAny());
      }
    }
    assertNotNull(definition);
  }
Example #3
0
  public static Webservices getProxy() {

    final JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
    proxyFactory.setServiceClass(Webservices.class);
    SettingsDataProvider settings = BeanProvider.getContextualReference(SettingsDataProvider.class);
    proxyFactory.setAddress(settings.getSetting("cmdbuild_url"));
    Object proxy = proxyFactory.create();

    final Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
    outProps.put(WSHandlerConstants.USER, settings.getSetting("cmdbuild_login"));
    outProps.put(
        WSHandlerConstants.PW_CALLBACK_REF,
        new ClientPasswordCallback(settings.getSetting("cmdbuild_pwd")));

    final Client client = ClientProxy.getClient(proxy);
    final Endpoint cxfEndpoint = client.getEndpoint();
    long timeout = 9000000000L;
    if (client != null) {
      HTTPConduit conduit = (HTTPConduit) client.getConduit();
      HTTPClientPolicy policy = new HTTPClientPolicy();
      policy.setConnectionTimeout(timeout);
      policy.setReceiveTimeout(timeout);
      conduit.setClient(policy);
    }
    cxfEndpoint.getOutInterceptors().add(new WSS4JOutInterceptorWOExpire(outProps));

    return (Webservices) proxy;
  }
Example #4
0
  public void connect(TokenHolder tokenHolder) {
    for (Class<? extends PublicInterface> interface1 : interfaces) {
      JaxWsProxyFactoryBean cpfb = new JaxWsProxyFactoryBean();
      cpfb.setServiceClass(interface1);
      cpfb.setAddress(address + "/" + interface1.getSimpleName());
      Map<String, Object> properties = new HashMap<String, Object>();
      properties.put("mtom-enabled", Boolean.TRUE);
      cpfb.setProperties(properties);

      PublicInterface serviceInterface = (PublicInterface) cpfb.create();

      client = ClientProxy.getClient(serviceInterface);
      HTTPConduit http = (HTTPConduit) client.getConduit();
      http.getClient().setConnectionTimeout(360000);
      http.getClient().setAllowChunking(false);
      http.getClient().setReceiveTimeout(320000);

      if (!useSoapHeaderSessions) {
        ((BindingProvider) serviceInterface)
            .getRequestContext()
            .put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
      }
      add(interface1.getName(), serviceInterface);
    }
    tokenHolder.registerTokenChangeListener(this);
    notifyOfConnect();
  }
 protected static ReportIncidentEndpoint createCXFClient() {
   // we use CXF to create a client for us as its easier than JAXWS
   JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
   factory.setServiceClass(ReportIncidentEndpoint.class);
   factory.setAddress(ADDRESS);
   return (ReportIncidentEndpoint) factory.create();
 }
 protected static MineEndpoint createCXFClient(String url) {
   // we use CXF to create a client for us as its easier than JAXWS and works
   JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
   factory.setServiceClass(MyEndpointService.class);
   factory.setAddress(url);
   return (MineEndpoint) factory.create();
 }
  private static <T> T createClient(
      String port, Class<T> serviceClass, SchemaValidationType type, Feature... features) {
    JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
    clientFactory.setServiceClass(serviceClass);

    clientFactory.setAddress(getAddress(port, serviceClass));

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

    @SuppressWarnings("unchecked")
    T newClient = (T) clientFactory.create();

    Client proxy = ClientProxy.getClient(newClient);

    if (type != null) {
      proxy.getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, type);
    }

    HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
    // give me longer debug times
    HTTPClientPolicy clientPolicy = new HTTPClientPolicy();
    clientPolicy.setConnectionTimeout(1000000);
    clientPolicy.setReceiveTimeout(1000000);
    conduit.setClient(clientPolicy);

    return newClient;
  }
Example #8
0
 protected static OrderEndpoint createCXFClient() {
   // we use CXF to create a client for us as its easier than JAXWS and works
   JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
   factory.setServiceClass(OrderEndpoint.class);
   factory.setAddress(URL);
   return (OrderEndpoint) factory.create();
 }
Example #9
0
  @Test
  public void testGet() {
    // Create the client
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setBus(getStaticBus());
    proxyFac.setAddress("http://localhost:" + PORT + "/jaxws/addmex");
    proxyFac.getFeatures().add(new LoggingFeature());
    MetadataExchange exc = proxyFac.create(MetadataExchange.class);
    Metadata metadata = exc.get2004();
    assertNotNull(metadata);
    assertEquals(2, metadata.getMetadataSection().size());

    assertEquals(
        "http://schemas.xmlsoap.org/wsdl/", metadata.getMetadataSection().get(0).getDialect());
    assertEquals(
        "http://apache.org/cxf/systest/ws/addr_feature/",
        metadata.getMetadataSection().get(0).getIdentifier());
    assertEquals(
        "http://www.w3.org/2001/XMLSchema", metadata.getMetadataSection().get(1).getDialect());

    GetMetadata body = new GetMetadata();
    body.setDialect("http://www.w3.org/2001/XMLSchema");
    metadata = exc.getMetadata(body);
    assertEquals(1, metadata.getMetadataSection().size());
    assertEquals(
        "http://www.w3.org/2001/XMLSchema", metadata.getMetadataSection().get(0).getDialect());
  }
Example #10
0
  public static void main(String[] args) {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(HelloWorld.class);
    factory.setAddress("http://localhost:9000/ws/HelloWorld");

    HelloWorld helloWorld = (HelloWorld) factory.create();
    System.out.println(helloWorld.sayHi("chendu"));
  }
Example #11
0
  private Echo createClientProxy() {
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setServiceClass(Echo.class);
    proxyFac.setAddress("local://Echo");
    proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID);

    return (Echo) proxyFac.create();
  }
Example #12
0
  public static void main(String[] args) throws Exception {

    JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();
    factoryBean.setAddress("");
    // factoryBean.set
    String url = "http://ho.gymbomate.com/GymboreeHOServices/HOServices.asmx?wsdl";
    String operationName = "GetMemPoints";
    System.out.println(call(url, operationName, "15618580940"));
  }
Example #13
0
  public Protocol(URL url, Authenticator transport) {
    final JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(WSMAN.class);
    factory.setAddress(url.toString());
    factory.setBindingId("http://schemas.xmlsoap.org/wsdl/soap12/");
    wsmanService = WSMAN.class.cast(factory.create());

    this.transport = transport;
  }
Example #14
0
 private CreditAgencyWS getProxy() {
   // Here we use JaxWs front end to create the proxy
   JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
   ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
   clientBean.setAddress(creditAgencyAddress);
   clientBean.setServiceClass(CreditAgencyWS.class);
   clientBean.setBus(BusFactory.getDefaultBus());
   return (CreditAgencyWS) proxyFactory.create();
 }
Example #15
0
 // 调试用
 @Ignore
 @Test
 public void rawTestWsClient() {
   JaxWsProxyFactoryBean bean = new JaxWsProxyFactoryBean();
   bean.setAddress(
       "http://10.17.35.103:8080/dubbo-test/services/vision.apollo.jaxws.HelloService");
   bean.setServiceClass(HelloService.class);
   bean.getHandlers().add(TraceHandler.getSingleton());
   HelloService s = (HelloService) bean.create();
   String r = s.sayHello("ZHAHH");
   System.out.println(r);
 }
Example #16
0
  @Test
  public void testClientProxyFactory() {

    JaxWsProxyFactoryBean cf = new JaxWsProxyFactoryBean();
    cf.setAddress("http://localhost:" + PORT + "/test");
    cf.setServiceClass(Greeter.class);
    cf.setBus(getBus());
    Configurer c = getBus().getExtension(Configurer.class);
    c.configureBean("client.proxyFactory", cf);
    Greeter greeter = (Greeter) cf.create();
    Client client = ClientProxy.getClient(greeter);
    checkAddressInterceptors(client.getInInterceptors());
  }
Example #17
0
  public BookstoreClient(String config) throws MuleException {
    // create mule
    muleContext = new DefaultMuleContextFactory().createMuleContext(config);
    muleContext.start();

    // create client
    JaxWsProxyFactoryBean pf = new JaxWsProxyFactoryBean();
    pf.setServiceClass(Bookstore.class);
    pf.setAddress("http://localhost:8777/services/bookstore");
    bookstore = (Bookstore) pf.create();

    // add a book to the bookstore
    Book book = new Book(1, "J.R.R. Tolkien", "The Lord of the Rings");
    bookstore.addBook(book);
  }
Example #18
0
  public static WsvasOrderService getWsvasOrderService() {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(WsvasOrderService.class);
    String url = JikeConfigUtil.getValue("fee.webservice.url");
    if (StringUtils.isEmpty(url)) {
      throw new RuntimeException("计费通道远程接口url未配置");
    }
    factory.setAddress(url);

    WsvasOrderService service = (WsvasOrderService) factory.create();
    System.out.println(
        "-----------------###################WsvasOrderService创建成功:"
            + service
            + "#############------------------");
    return service;
  }
Example #19
0
  public static GetPhoneRegionService getGetPhoneRegionService() {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(GetPhoneRegionService.class);
    String url = JikeConfigUtil.getValue("fee.webservice.getPhoneRegion.url");
    if (StringUtils.isEmpty(url)) {
      throw new RuntimeException("查询手机号归属地远程接口url未配置");
    }
    factory.setAddress(url);

    GetPhoneRegionService service = (GetPhoneRegionService) factory.create();
    System.out.println(
        "-----------------###################GetPhoneRegionService创建成功:"
            + service
            + "#############------------------");
    return service;
  }
Example #20
0
  public static void main(String[] args) {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(EccWService.class);
    factory.setAddress("http://10.2.31.220:8080/gmhx/service/eccWService");
    EccWService service = (EccWService) factory.create();

    EccBrand eccBrand = new EccBrand();
    eccBrand.setProdh("1");
    eccBrand.setStufe("1");
    eccBrand.setUpdateFlag("1");
    eccBrand.setVtext("1");

    List<EccBrand> list = new ArrayList<EccBrand>();
    list.add(eccBrand);
    service.handleEccBrand(list);
  }
Example #21
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();
  }
  @SuppressWarnings("rawtypes")
  private ProductService getSecuredProxy(String login, final String password) {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(ProductService.class);
    factory.setAddress(WSS4J_POC_SERVER_URL);
    List<Interceptor> inInterceptors = new ArrayList<Interceptor>();
    inInterceptors.add(new LoggingInInterceptor());
    List<Interceptor> outInterceptors = new ArrayList<Interceptor>();
    outInterceptors.add(new LoggingOutInterceptor());
    outInterceptors.add(new SAAJOutInterceptor());
    final Map<String, Object> authConfig = new HashMap<String, Object>();

    authConfig.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    authConfig.put(WSHandlerConstants.USER, login);
    authConfig.put(WSHandlerConstants.PASSWORD_TYPE, "PasswordText");

    authConfig.put(
        WSHandlerConstants.PW_CALLBACK_REF,
        new CallbackHandler() {
          public void handle(Callback[] callbacks)
              throws IOException, UnsupportedCallbackException {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
            pc.setIdentifier((String) authConfig.get(WSHandlerConstants.USER));
            pc.setPassword(password);
          }
        });

    outInterceptors.add(new WSS4JOutInterceptor(authConfig));
    factory.setInInterceptors(inInterceptors);
    factory.setOutInterceptors(outInterceptors);

    return (ProductService) factory.create();
  }
  public static void main(String[] args) {
    //		ApplicationContext context = new
    // FileSystemXmlApplicationContext("D:\\java\\workspace\\HuaWeiInterface\\target\\HuaWeiInterface-0.0.1-SNAPSHOT\\WEB-INF\\applicationContext.xml");
    //		  HelloWorld client = (HelloWorld)context.getBean("client");
    //        String res = client.sayHello("AAA");
    //        System.out.println(res);

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(Speech2Text.class);
    factory.setAddress("http://localhost:8080/HuaweiInterface/huawei");
    Speech2Text service = (Speech2Text) factory.create();

    String voiceFilePath = "";
    String resultFilePath = "";
    String grammarFilePath = "";
    AnaParams params = null;
    List<SpeechPojo> speechList = new ArrayList<SpeechPojo>();
    //
    service.speech2Text(voiceFilePath, resultFilePath, grammarFilePath, params, speechList);
    //        System.out.println("The order ID is " + result);

  }
Example #24
0
  public static boolean doSsoLogin(
      ServletRequest request, ServletResponse response, FilterChain filterChain) {
    try {
      HttpSession session = ((HttpServletRequest) request).getSession(true);
      // 临时登录超时时间
      session.setMaxInactiveInterval(60 * 3);
      String ssoValue = request.getParameter(ssoKey);
      try {
        ssoValue = RmCryptoHelper.decryptDesBase64(ssoValue);
      } catch (Exception e) {
        e.printStackTrace();
      }
      String[] ssoValueArgs = ssoValue.split(splictKeyRegex);
      String nodeId = ssoValueArgs[0];
      String sessionId = ssoValueArgs[2];
      String callWsUrl =
          RmClusterConfig.getSingleton()
              .getSelfNode()
              .get(RmClusterConfig.NodeKey.webServiceUrl.name());
      String address = callWsUrl + "RmSsoLogin";
      JaxWsProxyFactoryBean jw = new JaxWsProxyFactoryBean();
      jw.setServiceClass(IRmSsoService.class);
      jw.setAddress(address);
      Object obj = jw.create();
      IRmSsoService ssoService = (IRmSsoService) obj;

      RmUserVo userVo = ssoService.copyLogin(sessionId, ssoValue);
      session.setAttribute(IGlobalConstants.RM_USER_VO, userVo);
      session.setAttribute(IGlobalConstants.RM_SSO_TEMP, IGlobalConstants.RM_YES);
      return true;
    } catch (Exception e) {
      log.error("doSsoLogin():" + e.toString() + " cause:" + e.getCause());
      // save error
      request.setAttribute("org.apache.struts.action.EXCEPTION", e);
      return false;
    }
  }
Example #25
0
  public void setupSerial(String port) {

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.getInInterceptors().add(new LoggingInInterceptor());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    factory.setServiceClass(ArduinoWS.class);
    factory.setAddress("http://localhost:8084/ArduinoWS/ArduinoWSService");
    ArduinoWS client = (ArduinoWS) factory.create();
    String reply = client.setupArduinoSerial(port);
  }
Example #26
0
  public ArrayList<String> getSerialPorts() {

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.getInInterceptors().add(new LoggingInInterceptor());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    factory.setServiceClass(ArduinoWS.class);
    factory.setAddress("http://localhost:8084/ArduinoWS/ArduinoWSService");
    ArduinoWS client = (ArduinoWS) factory.create();
    ArrayList<String> reply = (ArrayList<String>) client.getSerialPortNames();
    return reply;
  }
Example #27
0
  public static void main(String args[]) throws Exception {

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.getInInterceptors().add(new LoggingInInterceptor());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    factory.setServiceClass(TestService.class);
    // factory.setAddress("http://localhost:9098/testService");
    factory.setAddress("http://localhost:9099/testService");

    TestService client = (TestService) factory.create();

    String reply = client.sayHi("HI");
    System.out.println("Server said: " + reply);
    System.exit(0);
  }
  @Bean
  CustomerRealmWebService customerRealmWebService(
      Environment environment,
      AccessTokens accessTokens,
      CustomerRealmProperties customerRealmProperties) {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setAddress(customerRealmProperties.getServiceUrl());
    factory.setServiceClass(CustomerRealmWebService.class);
    OAuth2TokenInterceptor oAuth2TokenInterceptor =
        new OAuth2TokenInterceptor(accessTokens, SERVICE_ID);
    factory.getOutInterceptors().add(oAuth2TokenInterceptor);

    if (environment.containsProperty("debug") || environment.containsProperty("trace")) {
      LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor();
      loggingInInterceptor.setPrettyLogging(true);
      LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
      loggingOutInterceptor.setPrettyLogging(true);
      factory.getInInterceptors().add(loggingInInterceptor);
      factory.getOutInterceptors().add(loggingOutInterceptor);
    }

    return (CustomerRealmWebService) factory.create();
  }
Example #29
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();
  }
  public static void main(String[] args) {

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

    factory.setServiceClass(ICalculator.class);
    factory.setAddress("http://localhost:8080/SOAPCalculator/soap?wsdl");
    factory.getInInterceptors().add(new LoggingInInterceptor());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    ICalculator client = (ICalculator) factory.create();
    Add request = new Add();

    request.setArg0(1);
    request.setArg1(10);

    int reply = client.add(request.getArg0(), request.getArg1());

    AddResponse response = new AddResponse();

    response.setReturn(reply);
    System.out.println("Response: " + response.getReturn());
  }