コード例 #1
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();
 }
コード例 #3
0
 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();
 }
コード例 #4
0
  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;
  }
コード例 #5
0
ファイル: RouteTest.java プロジェクト: nicomfe/FuseCXFTest
 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();
 }
コード例 #6
0
  //	@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===============");
    }
  }
コード例 #7
0
  @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();
  }
コード例 #8
0
ファイル: CMDBuildUtils.java プロジェクト: ossbase/p1
  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;
  }
コード例 #9
0
ファイル: Client.java プロジェクト: chendu/cxfstudy
  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"));
  }
コード例 #10
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();
  }
コード例 #11
0
ファイル: Protocol.java プロジェクト: apifocal/wsman4j
  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;
  }
コード例 #12
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);
  }
コード例 #13
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;
  }
コード例 #14
0
ファイル: ClientTest.java プロジェクト: GeeQuery/cxf-plus
 // 调试用
 @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);
 }
コード例 #15
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());
  }
コード例 #16
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);
  }
コード例 #17
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);
  }
コード例 #18
0
ファイル: TestService.java プロジェクト: RoyZeng/gmhx
  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);
  }
コード例 #19
0
ファイル: CxfClientUtil.java プロジェクト: andygb/newjike
  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;
  }
コード例 #20
0
ファイル: CxfClientUtil.java プロジェクト: andygb/newjike
  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;
  }
コード例 #21
0
ファイル: ExceptionTest.java プロジェクト: CzarnyPeter/cxf
  @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();
  }
コード例 #22
0
  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());
  }
コード例 #23
0
  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);

  }
コード例 #24
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();
  }
コード例 #25
0
ファイル: RmSsoLogin.java プロジェクト: show123456/javasec
  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;
    }
  }