- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我创建了一个简单的 web 服务,它实现了一个添加操作,并使用 wsimport 创建了一些客户端文件。现在我想包含尽可能少的 wsdl 特定工件。以下是如何调用 Web 服务的示例:
String serviceNamespace = "http://jws.samples.geronimo.apache.org/";
String serviceName = "CalculatorServiceService";
QName serviceQN = new QName(serviceNamespace, serviceName);
Service service = Service.create(new URL("http://localhost:8080/WebService/calculator?wsdl"), serviceQN);
String portNamespace = "http://jws.samples.geronimo.apache.org/";
String portName = "CalculatorServicePort";
QName portQN = new QName(portNamespace, portName);
Calculator myProxy = (Calculator) service.getPort(portQN, Calculator.class);
但似乎我必须为每条消息包含包装器类。例如添加操作的结果消息:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "addResponse", propOrder = { "_return" })
public class AddResponse {
@XmlElement(name = "return")
protected int _return;
public int getReturn() {
return _return;
}
public void setReturn(int value) {
this._return = value;
}
}
这些包装器在服务接口(interface)的注释中使用:
@WebService(name = "Calculator", targetNamespace = "http://jws.samples.geronimo.apache.org/")
public interface Calculator {
@WebMethod
@RequestWrapper(className = "org.example.webservices.clients.dynamicproxy.Add")
@ResponseWrapper(className = "org.example.webservices.clients.dynamicproxy.AddResponse")
public int add(
@WebParam(name = "value1", targetNamespace = "")
int value1,
@WebParam(name = "value2", targetNamespace = "")
int value2);
}
如果注释被删除,Web 服务将不会运行。
com.sun.xml.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class org.example.webservices.clients.dynamicproxy.jaxws.Add is not found. Have you run APT to generate them?
但为什么我需要那些包装器? JAX-WS 不能即时创建这些包装器吗?您是否看到任何无法从 wsdl 文件中检索到的信息?
最佳答案
默认情况下,您的服务是 WRAPPED,而不是 BARE,因此消息中的顶级项目必须是与操作同名的类型。在“经典”JAX-WS 中,这需要您添加包装器类型。
如果您使用 Apache CXF ,它将使用 ASM 自动生成这些包装器。
关于java - 为什么 JAX-WS 需要包装类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3708631/
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 是基
我是一名优秀的程序员,十分优秀!