【问题标题】:How to auto generate WSDL File using HTTPBinding如何使用 HTTPBinding 自动生成 WSDL 文件
【发布时间】:2023-03-17 17:46:02
【问题描述】:

我是 Web 服务的新手。我尝试了这里给出的一个例子

https://examples.javacodegeeks.com/enterprise-java/jws/jax-ws-hello-world-example-rpc-style/

在这里,当我在 tomcat 上部署 Web 应用程序时,它会打开一个网页,单击它会定向到 WSDL。在这里,我创建了 Java 存根类,并动态创建了 WSDL。我尝试为另一个 Web 服务做类似的事情,但在这里使用 HTTPBinding 。但我看到WSDL 没有发布。

我尝试了很多方法,但都没有成功。

下面是我创建的 Impl 类

@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/sayhelloWSDL 链接上都没有得到 Webservice 结果,就像在 SOAP 示例中显示的那样。

有人可以帮我理解如何使用HTTPBinding 吗?

非常感谢。

【问题讨论】:

标签: java http binding wsdl


【解决方案1】:
  • 我尝试使用 wsgen 工具为上述创建 WSDL 文件 网络服务 。但它给出了消息“wsgen 无法生成 WSDL 非 SOAP 绑定:http://www.w3.org/2004/08/wsdl /http on Class com.pkg.WbServeImpl" 我认为这就是为什么 Eclipse 也不是 在我的 Web 服务启动并运行时生成 WSDL。对于 HTTP 绑定 必须手动编写和发布 WSDL。 - 谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-01
    • 1970-01-01
    • 2012-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-18
    • 1970-01-01
    相关资源
    最近更新 更多