- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我开始使用 JAX WS 研究 Java Web 服务。我正在阅读的书的第一章展示了如何仅使用 java SE 构建和部署简单的 jax ws web 服务。特别是,Web 服务是通过 Endpoint 类发布的。发布 Web 服务后,作者指定“开箱即用,端点发布者一次处理一个客户端请求time ... 如果给定请求的处理应该挂起,那么所有其他客户端请求都被有效阻止。一个例子在最后本章展示 Endpoint 如何并发处理请求这样一个挂起的请求就不会阻止其他请求。”
为了看到这一点,我尝试向具有 2 个线程的 Web 服务发送两个请求。这是代码:
@WebService(endpointInterface = "ProveVelociJava.WS.MyWsWithJavaSE.SayHello")
public class SayHelloImpl implements SayHello {
public String greetings(String param) {
System.out.println("\nStarting " + param + "...\n");
if(param.equals("miao")) {
try {
Thread.sleep(9000);
}
catch(Exception e) {}
}
System.out.println("Ended " + param + "\n\n");
return "Hi, " + param;
}
}
public class SayHelloPublisher {
public static void main(String[ ] args) {
// 1st argument is the publication URL
// 2nd argument is an SIB instance
Endpoint.publish("http://127.0.0.1:9899/say", new SayHelloImpl());
}
}
class MyClient extends Thread {
private static URL url;
private static QName qname;
private static Service service;
private static SayHello eif;
static {
try {
url = new URL("http://127.0.0.1:9899/say?wsdl");
qname = new QName("http://MyWsWithJavaSE.WS.ProveVelociJava/", "SayHelloImplService");
service = Service.create(MyClient.url, MyClient.qname);
// Extract the endpoint interface, the service "port".
eif = service.getPort(SayHello.class);
}
catch(Exception e) {}
}
private String name;
public MyClient(String n) {
name = n;
}
public void run() {
System.out.println(MyClient.eif.greetings(this.name));
}
public static void main(String args[ ]) throws Exception {
MyClient t1 = new MyClient("miao");
MyClient t2 = new MyClient("bau");
t1.start();
t2.start();
}
}
如果我启动 MyClient 类,名为“miao”的线程发送它的请求然后进入休眠状态。但是,名为“bau”的线程不会等待前一个线程,它的请求会立即得到满足。
我错过了什么吗? java线程可以模拟多个请求吗?
非常感谢您的帮助,妮可。
最佳答案
我下载了 JAX-WS 2.0 规范,它反驳了我正在阅读的书所说的内容:
"An endpoint consists of an object that acts as the Web service implementation (called here implementor) plus some configuration information ... An Endpoint will be typically invoked to serve concurrent requests, so its implementor should be written so as to support multiple threads. The synchronized keyword may be used as usual to control access to critical sections of code. For finer control over the threads used to dispatch incoming requests, an application can directly set the executor to be used"
(http://jcp.org/aboutJava/communityprocess/final/jsr224/index.html,第 5.2.2 节“发布”,第 67 页)
这本书谈到了 JAX-WS 2.1,但我没能下载该版本的规范。无论如何,JAX-WS 2.2 规范(当前版本)确认了 Endpoint 类的并发性质(它包含与上述相同的语句)。
我不知道这本书的作者到底是什么意思。
关于jax-ws - JAX WS 多请求管理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11587646/
Apache CXF 可以完成任务。但我想在没有任何 spring 依赖的情况下组合它。提前谢谢你! 最佳答案 JAX-WS 和 JAX-RS 都是 Java EE 6 的一部分.因此,您可以在不使用
Apache CXF 可以完成任务。但我想在没有任何 spring 依赖的情况下组合它。提前谢谢你! 最佳答案 JAX-WS 和 JAX-RS 都是 Java EE 6 的一部分.因此,您可以在不使用
所以我的意思是你有一个分类特征 $X$(假设你已经把它变成了整数)并说你想使用特征 $A$ 将它嵌入到某个维度中,其中 $A$ 是 arity x n_embed . 通常的做法是什么?使用 for
所以我的意思是你有一个分类特征 $X$(假设你已经把它变成了整数)并说你想使用特征 $A$ 将它嵌入到某个维度中,其中 $A$ 是 arity x n_embed . 通常的做法是什么?使用 for
我知道网上有很多文档主要描述技术差异。 但是我很想知道您更喜欢一种特定类型而不是其他类型的常见用例是什么? 这些偏好是因为集成模式/产品支持特定类型吗? 最佳答案 谢谢你的回答。然而实际用例差异以及何
我想将 CXF 与 Google Guice 集成。我已经在我的项目中使用 Guice,并且我想避免添加额外的依赖项。 CXF 是我的选择,因为要求之一是能够向服务用户提供 XML、JSON、JSON
来自 JSR-339: For simplicity, JAX-RS implementations are NOT REQUIRED to support processing groups oth
我开始使用 JAX WS 研究 Java Web 服务。我正在阅读的书的第一章展示了如何仅使用 java SE 构建和部署简单的 jax ws web 服务。特别是,Web 服务是通过 Endpoin
在 JAX 的快速入门教程中,我发现可以使用以下代码行为可微函数 fun 高效地计算 Hessian 矩阵: from jax import jacfwd, jacrev def hessian(fu
JAX-RS 提供了 StreamingOutput 接口(interface),我们可以实现它来对我们的响应主体进行原始流处理。 public interface StreamingOutput {
有没有办法获得java.lang.reflect.Method为给定的 @Path 调用的方法(用 HttpServletRequest 注释) ? 这是我的用例:我在 Java EE 中 Filte
我接到了一家公司的任务,该任务向我发送了一台已完成所有设置的虚拟机。任务是我必须创建一个 API 来从数据库中检索人员详细信息并显示它。 问题是,当我运行应用程序时,服务器返回一个包含 hello w
我有一个 POST 方法调用,它接受很少的表单参数。我希望 JAX-RS 能够处理不存在特定表单参数的情况。 示例: @POST @Produces (MediaType.APPLICATION_JS
我有 JAX-RS 网络应用程序,我想记录从获取请求到响应的时间量。在带有 servlet 过滤器的 Spring Boot 中很容易。但是我的应用程序中的过滤器无法正常工作: @Provider p
使用以下网址。 http://doma.in/context/resource/some/.../undefined 我想获取 ../resource 之后的路径名,即 /some/.../undef
我编写了 2 个 Web 服务,一个使用 Jax-WS,一个使用 Jax-RPC。他们只是返回一个字符串。 我使用 jMeter 进行了压力测试,奇怪的是,Jax-RPC 速度更快。 我什么时候才能在
我花了几个小时在嵌入式 Jetty 9.1.0.v20131115 和 RESTEasy 3.0.5.Final 中安装自定义登录服务。我的登录服务将在数据库中查找用户并为他们分配角色。它看起来像这样
有没有办法操纵jaxws中使用的编码器。 我喜欢发送一个在网络服务请求中提交的 cdata,为此我想在这里尝试类似描述的东西:http://odedpeer.blogspot.de/2010/07/j
我想从 java 服务器 (Restful Jax-rs) 发送图像。我的客户是安卓。 @GET public Response getUserImage() { byte[] image =new
我对网络服务很陌生。我找不到 JAX-WS 和 CXF 之间的区别。 据我了解,JAX-WS是java提供的规范,CXF是实现。 如果我错了,请纠正我。 最佳答案 是的,你是对的。 JAX-WS 是基
我是一名优秀的程序员,十分优秀!