eclipse 如何在 Java 中使用/调用/调用具有 HttpBasicAuthentication 的 SOAP Web 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11738022/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:42:25  来源:igfitidea点击:

How to consume/call/invoke the SOAP web service which has HttpBasicAuthentication in Java

javaeclipseweb-servicessoap

提问by Bhavesh Patel

I need your help. We are developing one web based application. Data to be displayed on the web pages (built on HTML5 JSP) are coming from the SOAP web services. We have all the SOAP web service which has HttpBasicAuthentication, that means when we access the web service we need to pass the username and password (i.e. authentication required for web service access). Can you please suggests how to call the web service from my web application ? Do we need to use any third party frameworks like Axis2... etc ? Please note, we are using HTML5, JSP, Java6, Tomcat 6 and Eclipse as development environment.

我需要你的帮助。我们正在开发一种基于 Web 的应用程序。要在网页上显示的数据(建立在 HTML5 JSP 上)来自 SOAP Web 服务。我们拥有所有具有 HttpBasicAuthentication 的 SOAP Web 服务,这意味着当我们访问 Web 服务时,我们需要传递用户名和密码(即 Web 服务访问所需的身份验证)。你能建议如何从我的网络应用程序调用网络服务吗?我们是否需要使用任何第三方框架,如 Axis2... 等?请注意,我们使用 HTML5、JSP、Java6、Tomcat 6 和 Eclipse 作为开发环境。

Appreciate your quick help.

感谢您的快速帮助。

Thanks in advance.

提前致谢。

回答by Murugesh

I.Third party tools to consume the WebServices in your Web Applications are

I. 在您的 Web 应用程序中使用 WebServices 的第三方工具是

  1. Axis
  2. Apache-cxf
  3. Apache-Rampart (For Axis Security)
  1. Apache-cxf
  2. Apache-Rampart(用于 Axis 安全性)

All you need to do is pass the WSDL URL to any of the utilities,and it will give client stubs, those you can use it in your Web Application.

您需要做的就是将 WSDL URL 传递给任何实用程序,它会提供客户端存根,您可以在 Web 应用程序中使用它。

II.Since your are using java6,it is having wsgen and wsimport utilities for WebServices,you can have any scripts (say ANT scripts) to invoke appropriate java6 utility.

II.由于您使用的是java6,它具有用于WebServices 的wsgen 和wsimport 实用程序,您可以使用任何脚本(例如ANT 脚本)来调用适当的java6 实用程序。

III. More simply, you can generate the WebSerivce client stubs from Eclipse itself.Later you can copy the packages of client and required JAR's in classpath in your WebApplication

三、更简单地说,您可以从 Eclipse 本身生成 WebSerivce 客户端存根。稍后您可以在您的 WebApplication 的类路径中复制客户端和所需 JAR 的包

For Eclipse WS client : http://www.eclipse.org/webtools/jst/components/ws/1.5/tutorials/WebServiceClient/WebServiceClient.html

对于 Eclipse WS 客户端:http: //www.eclipse.org/webtools/jst/components/ws/1.5/tutorials/WebServiceClient/WebServiceClient.html