WebServices 客户端 - 动态代理与使用 wconsume 创建的存根
我使用 JaxWs 创建了一个 Web 服务。我相信存在两种在客户端使用 Web 服务的方法。
- 使用 wconsume e 将生成的类作为客户端中的存根。
- 使用动态代理,这意味着不会有文件作为存根发送到客户端。
我想这种方法的唯一优点是,如果 wsdl 发生更改,则不需要生成存根文件。然而,它看起来不太实用,因为我可能需要更改客户端代码中的某些内容并重新编译。我还没有使用过这个技术。当我研究我需要的原因时,我发现这个选项在开发Java客户端时生成代理文件,但在使用.Net时却没有。
然后,我有两个问题:
- 存根和动态代理技术有什么区别?
- 为什么.Net客户端不需要代理文件?或者是否有自动生成的文件,但我不知道在哪里可以找到?使用存根与动态代理相比,我是否会损失性能或安全性?
I created a Web Service using JaxWs. I belive that exist two ways to consume a web service in the client.
- using wconsume e putting the generated classes as stubs in the client.
- using Dynamic Proxy, whitch means, there wil be no files to be send to client as stubs.
I imagine that the only advantage of this approach is that if the wsdl changed, there will be not need to generat stubs files. However it doesn't look too practical, as I will probably need to change something in the client code and recompiled anyway. I didn't use this tecnichy yet. I found this option when I was reaserching the reason why I need to generate proxy file when developping Java client but I didn't when I using .Net.
Then, I have two question:
- What's the difference between stubs and Dynamic Proxy tecnich?
- Why .Net client doesn't need proxies files? Or is there the files automaticlly generated and I don't know where to find? Am I loosing performance or security when using stubs versus dynamic proxy?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JAX-RPC 已弃用。
新标准是 JAX-WS。
JAX-WS 允许程序员调用 Web 服务,就像进行本地方法调用一样。
为此,定义了从 WSDL 到 Java 的标准映射。
此映射将
wsdl:port
定义与称为服务端点接口 (SEI
) 的 JavaInterface
相关联。SEI
是 Web 服务端点的 Java 表示形式。在运行时,JAX-WS 创建一个 SEI 实例,只需在 SEI 上进行方法调用即可使用该实例来进行 Web 服务调用。
现在用于创建 SEI 实例的方法是通过动态代理类。
由于它是动态创建的,因此称为动态代理。
不需要存根来实现代理,但 SEI 必须已经实现才能使用。
代理使用/基于由 WSDL 生成的存根类来运行。
所以存根是先决条件。
因此,正如您在帖子中所说,技术没有分离。
你误解了这个概念
JAX-RPC is deprecated.
The new standard is JAX-WS.
JAX-WS allows programmers to invoke a web service, as if they were making a local method call.
For this to happen a standard mapping from WSDL to Java has been defined.
This mapping correlates a
wsdl:port
definition with a JavaInterface
which is called Service Endpoint Interface (SEI
).The
SEI
is the Java representation of the web service endpoint.At runtime JAX-WS creates an instance of a SEI that can be used to make web service calls by simply making method calls on the SEI.
Now the way used to create an instance of a SEI is via the dynamic proxy class.
It is called dynamic proxy since it is created dynamically.
No stubs are need to implement a proxy, but the SEI must already have been implemented in order to be used.
The proxy uses/is based on the stub classes to function, which have been generated by the WSDL.
So the stubs are a prerequisite.
So there is no separation of techniques as you say in your post.
You have misunderstood the concept