如何使用HTTPBinding自动生成WSDL文件
问题描述:
我是Web服务的新手。我试图给出的例子在这里如何使用HTTPBinding自动生成WSDL文件
https://examples.javacodegeeks.com/enterprise-java/jws/jax-ws-hello-world-example-rpc-style/
这里当我部署在Tomcat Web应用程序,它会打开一个网页,点击它指向WSDL
。在这里,我创建了Java存根类,WSDL
即时创建。类似的事情,我试图做另一个Web服务但在这里使用HTTPBinding
。但我看到WSDL
未发布。
我尝试了很多方法,但没有成功。
下面是我创建
@WebServiceProvider()
@ServiceMode(value=Service.Mode.MESSAGE)
@BindingType(value = HTTPBinding.HTTP_BINDING)
public class WebServiceImpl implements Provider<Source> {
public Source invoke(Source source) {
try {
return new StreamSource(new ByteArrayInputStream(printMessage().getBytes()));
} catch(Exception e) {
e.printStackTrace();
throw new RuntimeException("Error in provider endpoint", e);
}
}
public String printMessage() {
String body= "Hello , Congratulations to learn HTTP Binding .happy learning!";
return body;
}
的实现类,但我既不在URL localhost:8080/HttpWS/sayhello
也不WSDL
链接得到Webservice的结果,就像是在SOAP示例所示。
有人可以帮助我理解如何使用HTTPBinding
?
非常感谢。
答
- 我试图使用wsgen工具为以上 WebService创建WSDL文件。但它给消息“wsgen不能生成WSDL 非SOAP绑定:http://www.w3.org/2004/08/wsdl/http上 com.pkg.WbServeImpl”我认为这就是为什么Eclipse也不是 生成WSDL,而我的web服务启动并运行。对于HTTP绑定 必须手动编写和发布WSDL。 - 由于
修改标签@WebServiceProvider( \t \t PORTNAME = “WebServiceImplPort”, \t服务名= “WebServiceImplService”, \t的targetNamespace =之后的 “http://jaxws.webservices.examples/”, \t wsdlLocation =“http:// localhost:8080/HttpWS/sayhello?wsdl”)我正在获取XML Hello,恭喜你学习HTTP在访问URL http:// localhost:8080/HttpWS/sayhello时绑定.happy学习 ns:printMessageResponse>。但是由此产生的WSDL还没有得到答案。请帮忙 。 –
summary