简体   繁体   English

JAX-WS Web服务,如何工作

[英]JAX-WS Web Service, how it works

I'm read official oracle tutorial, but dont understand this full. 我已经阅读了官方的oracle教程,但对这些内容并不了解。 I'm glad if we answer my questions. 如果我们回答我的问题,我感到很高兴。

Question 1. What's conceptual difference between JAX-WS Web Service and RMI? 问题1. JAX-WS Web服务和RMI之间在概念上有什么区别? Both RMI and JAX-WS can invoke remote method. RMI和JAX-WS都可以调用远程方法。

Question 2. Why we cant use servlets only for the features, that can be implemented by JAX-WS? 问题2.为什么我们不能仅将servlet用于JAX-WS可以实现的功能? Just declare init servlet's methods. 只需声明init servlet的方法即可。

Question 3. As i understand, web service JAX-WS can't get http response and http request whithout servlets, for example. 问题3。据我了解,例如,Web服务JAX-WS在没有servlet的情况下无法获得http响应和http请求。 It's just set of endpoints classes, whose contains WebMethods with their implementation. 它只是一组端点类,它们包含WebMethods及其实现。 Ie if we want to communicated with service through web-client we must declare appropriate servlet for this needs. 即,如果我们想通过web-client与服务进行通信,则必须为此声明合适的servlet。 This servlet will parse http request, invoke appropriate @WebMethod generate and sent http response. 该servlet将解析http请求,调用适当的@WebMethod生成并发送http响应。 Is it correct? 这是正确的吗?

Question 4. Is WSDL document just xml -file whose contain description availabl @WebMethod by this WEbService and all? 问题4. WSDL文档仅仅是xml -file,其包含描述由该WEbService提供的@WebMethod可用吗?

Question 5. From the official tutorial: 问题5.从官方教程中:

A client creates a proxy (a local object representing the service) and then simply invokes methods on the proxy.

Does client create a proxy based on service's WSDL -document? 客户端是否基于服务的WSDL文档创建代理?

My take on the answers in order: 我对答案的看法如下:

  • RMI invokes methods of remote Java objects directly from objects in other Java virtual machines and uses object serialization to marshal and unmarshal parameters. RMI直接从其他Java虚拟机中的对象调用远程Java对象的方法,并使用对象序列化来编组和取消编组参数。 Notice how all of this is Java-specific. 注意所有这些都是特定于Java的。 JAX-WS is about a Java API for leveraging standards (SOAP, WSDL, etc) to facilitate broader interoperability instead. JAX-WS是关于一种Java API,用于利用标准(SOAP,WSDL等)来促进更广泛的互操作性。 As a result, applications of all kinds can talk to each other--not just Java to Java. 结果,各种应用程序可以相互通信,而不仅仅是Java与Java。

  • With JAX-WS, you are using servlets. 通过JAX-WS,您正在使用servlet。 It's just that the specification provides an abstraction on top of the Servlet API. 只是规范提供了Servlet API之上的抽象。 It is always better to work with abstractions than with low-level implementation details. 与抽象一起工作总是比底层实现细节更好。 This frees you up to work on the interesting stuff and helps you avoid mistakes. 这使您可以腾出精力从事有趣的工作,并帮助您避免犯错。

  • I don't quite follow this question, but HttpServlet is the Java EE abstraction for all HTTP communication. 我不太关注这个问题,但是HttpServlet是所有HTTP通信的Java EE抽象。 So JAX-WS, JAX-RS, and other specifications rely on HttpServlet. 因此,JAX-WS,JAX-RS和其他规范依赖于HttpServlet。 You don't have to specify the servlets or anything. 您无需指定servlet或其他任何内容。 That's one of the many low-level details the abstractions free you from. 那是抽象使您摆脱困境的许多底层细节之一。

  • WSDL is a standard that transcends platform or implementation. WSDL是超越平台或实现的标准。 In other words, it has no idea about @WebMethod or any other implementation-specific details. 换句话说,它@WebMethod或任何其他特定于实现的细节。 It just defines the interface for interacting with the service. 它只是定义了与服务交互的接口。

  • Yes. 是。 WSDL's aren't meant to be consumed by humans. WSDL并非供人类使用。 They define the interface for interacting with the service, and clients (Java, .NET, whatever) use these to auto-generate stubs for you to use to call the services defined in the WSDL. 他们定义了与服务交互的接口,客户端(Java,.NET,无论如何)使用它们来自动生成存根,以便您调用WSDL中定义的服务。 The client generates the SOAP request for you and processes the SOAP response for you. 客户端为您生成SOAP请求并为您处理SOAP响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM