org.apache.cxf.jaxrs.client.WebClient.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中org.apache.cxf.jaxrs.client.WebClient.<init>()方法的一些代码示例,展示了WebClient.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.<init>()方法的具体详情如下:
包路径:org.apache.cxf.jaxrs.client.WebClient
类名称:WebClient
方法名:<init>

WebClient.<init>介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

public async void HandleButtonClick(object sender, EventArgs e)
{
  // All of this method will run in the UI thread, which it needs
  // to as it touches the UI... however, it won't block when it does
  // the web operation.

  string url = urlTextBox.Text;
  WebClient client = new WebClient();
  string webText = await client.DownloadStringTaskAsync(url);

  // Continuation... automatically called in the UI thread, with appropriate
  // context (local variables etc) which we used earlier.
  sizeTextBox.Text = string.Format("{0}: {1}", url, webText.Length); 
}

代码示例来源:origin: stackoverflow.com

WebView webview = new WebView();
webview.setWebViewClient(new WebClient());
webView.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("stackoverflow.com");

代码示例来源:origin: stackoverflow.com

WebClient client = new WebClient();
client.getOptions().setThrowExceptionOnScriptError(false);

代码示例来源:origin: stackoverflow.com

@Grapes(
  @Grab(group='net.sourceforge.htmlunit', module='htmlunit', version='2.8')
)

import com.gargoylesoftware.htmlunit.*
import com.gargoylesoftware.htmlunit.html.*

URL url = new URL("http://www.example.com");
StringWebResponse response = new StringWebResponse("<html><head><title>Test</title></head><body></body></html>", url);
WebClient client = new WebClient()
HtmlPage page = HTMLParser.parseHtml(response, client.getCurrentWindow());
System.out.println(page.getTitleText());

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) throws Exception {
   LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
   File file = new File("cookie.file");
   ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
   Set<Cookie> cookies = (Set<Cookie>) in.readObject();
   in.close();
   WebClient wc = new WebClient();
   Iterator<Cookie> i = cookies.iterator();
   while (i.hasNext()) {
     wc.getCookieManager().addCookie(i.next());
   }
   HtmlPage p = wc.getPage("http://google.com");
   ObjectOutput out = new ObjectOutputStream(new FileOutputStream("cookie.file"));
   out.writeObject(wc.getCookieManager().getCookies());
   out.close();
 }

代码示例来源:origin: stackoverflow.com

WebClient client = new WebClient();
HtmlPage page = client.getPage("http://stackoverflow.com");

// create a submit button - it doesn't work with 'input'
HtmlElement button = page.createElement("button");
button.setAttribute("type", "submit");

// append the button to the form
HtmlElement form = ...;
form.appendChild(button);

// submit the form
page = button.click();

代码示例来源:origin: stackoverflow.com

@Test
public void submittingForm() throws Exception {
  final WebClient webClient = new WebClient();

  // Get the first page
  final HtmlPage page1 = webClient.getPage("http://some_url");

  // Get the form that we are dealing with and within that form, 
  // find the submit button and the field that we want to change.
  final HtmlForm form = page1.getFormByName("myform");

  final HtmlSubmitInput button = form.getInputByName("submitbutton");
  final HtmlTextInput textField = form.getInputByName("userid");

  // Change the value of the text field
  textField.setValueAttribute("root");

  // Now submit the form by clicking the button and get back the second page.
  final HtmlPage page2 = button.click();

  webClient.closeAllWindows();
}

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) throws Exception {
  // turn off htmlunit warnings
  java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.OFF);
  java.util.logging.Logger.getLogger("org.apache.http").setLevel(java.util.logging.Level.OFF);

  WebClient webClient = new WebClient();
  HtmlPage page = webClient.getPage("http://stackoverflow.com");
  System.out.println(page.getTitleText());
}

代码示例来源:origin: stackoverflow.com

WebClient client = new WebClient();
Page page = client.getPage("http://stackoverflow.com/users/flair/97901.json");
WebResponse response = page.getWebResponse();
if (response.getContentType().equals("application/json")) {
  String json = response.getContentAsString();
  Map<String, String> map = new Gson().fromJson(json, new TypeToken<Map<String, String>>() {}.getType());
  System.out.println(map.get("displayName")); // Benju
}

代码示例来源:origin: stackoverflow.com

URL url = new File("test.html").toURI().toURL();
WebClient webClient = new WebClient(); 
HtmlPage page = webClient.getPage(url);

OutputStream os = null;
try{
  os = new FileOutputStream("test.pdf");

  ITextRenderer renderer = new ITextRenderer();
  renderer.setDocument(page,url.toString());
  renderer.layout();
  renderer.createPDF(os);
} finally{
  if(os != null) os.close();
}

代码示例来源:origin: stackoverflow.com

public ActionResult GetPdf(string filename)
{
  using (var client = new WebClient())
  {
    var buffer = client.DownloadData("http://foo.com/bar.pdf");
    return File(buffer, "application/pdf", "report1.pdf");
  }
}

代码示例来源:origin: stackoverflow.com

using (WebClient client = new WebClient())
{
 string json = "{\"user\":{\"email\":\"sample@zmail\",\"password\":\"28902890\"}}";
 client.UploadString("https://example.com/api/v1/sessions, json);
}

代码示例来源:origin: stackoverflow.com

using(WebClient client = new WebClient ())
{
  string url = "http://xxxxx.xxxxx.com/api/sendmsg.php?user=xxxx&pass=xxxx&sender=xxx&phone=xxxxxxxxxxx&text=this%20is%20test%20sms&priority=ndnd&stype=normal";
  client.DownloadString(url);
}

代码示例来源:origin: stackoverflow.com

public void ProcessRequest(HttpContext context) {
 WebClient myClient = new WebClient(); 

 //Fetch response on your server
 string response = myClient.DownloadString("http://example.com/webservice/webMethod");

 // Send response to your javascript.
 context.Response.Write(response);
}

代码示例来源:origin: stackoverflow.com

button.Click += async delegate
   {
     var destination = Path.Combine(
       System.Environment.GetFolderPath(
         System.Environment.SpecialFolder.ApplicationData),
         "music.mp3");
     await new WebClient().DownloadFileTaskAsync(
       new Uri("http://www.xyz.com/music.mp3"),
       destination);
   };

代码示例来源:origin: stackoverflow.com

WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(false);
int status = webClient.getPage("http://google.co.uk/ffffff").getWebResponse()
     .getStatusCode();
System.out.println(status);

代码示例来源:origin: stackoverflow.com

String html = "<html>Your html here</html>";
WebClient client = new WebClient();
MockWebConnection connection = new MockWebConnection();
connection.setDefaultResponse(html);
client.setWebConnection(connection);
HtmlPage page = client.getPage(someUrl);

代码示例来源:origin: stackoverflow.com

final WebClient webClient = new WebClient();
final HtmlPage page1 = webClient.getPage("http://www.facebook.com");
final HtmlForm form = page1.getFormByName("login_form");

final HtmlSubmitInput button = form.getInputsByValue("Log in");
final HtmlTextInput textField = form.getInputByName("email");
textField.setValueAttribute("jon@jon.com");
final HtmlTextInput textField = form.getInputByName("pass");
textField.setValueAttribute("ahhhh");
final HtmlPage page2 = button.click();

代码示例来源:origin: stackoverflow.com

public void submittingForm() throws Exception {
  WebClient webClient = new WebClient();
  HtmlPage page1 = webClient.getPage("http://some_url");
  HtmlForm form = page1.getFormByName("myform");
  HtmlSubmitInput button = form.getInputByName("submitbutton");
  HtmlTextInput textField = form.getInputByName("userid");
  textField.setValueAttribute("root");
  HtmlPage page2 = button.click();
}

代码示例来源:origin: stackoverflow.com

final WebClient webClient = new WebClient();
final HtmlPage page1 = webClient.getPage("http://www.facebook.com");
final HtmlForm form = (HtmlForm) page1.getElementById("login_form");

final HtmlSubmitInput button = (HtmlSubmitInput) form.getInputsByValue("Log In").get(0);
final HtmlTextInput textField = form.getInputByName("email");
textField.setValueAttribute("jon@jon.com");
final HtmlPasswordInput textField2 = form.getInputByName("pass");
textField2.setValueAttribute("ahhhh");
final HtmlPage page2 = button.click();

相关文章

WebClient类方法