Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用HTTPBinding自动生成WSDL文件_Java_Http_Binding_Wsdl - Fatal编程技术网

Java 如何使用HTTPBinding自动生成WSDL文件

Java 如何使用HTTPBinding自动生成WSDL文件,java,http,binding,wsdl,Java,Http,Binding,Wsdl,我不熟悉Web服务。我试过这里给出的一个例子 在这里,当我在tomcat上部署web应用程序时,它会打开一个网页,单击该网页将其定向到WSDL。在这里,我创建了Java存根类,WSDL是动态创建的。我尝试为另一个Web服务执行类似的操作,但这里使用的是HTTPBinding。但是我看到WSDL没有发布 我尝试了很多方法,但没有成功 下面是我创建的Impl类 @WebServiceProvider() @ServiceMode(value=Service.Mode.MESSAGE) @Bindi

我不熟悉Web服务。我试过这里给出的一个例子

在这里,当我在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;
}
@WebServiceProvider()
@ServiceMode(值=Service.Mode.MESSAGE)
@BindingType(值=HTTPBinding.HTTP\u BINDING)
公共类WebServiceImpl实现提供程序{
公共源调用(源){
试一试{
返回新的StreamSource(newbytearrayinputstream(printMessage().getBytes());
}捕获(例外e){
e、 printStackTrace();
抛出新的RuntimeException(“提供程序终结点中的错误”,e);
}
}
公共字符串printMessage(){
String body=“您好,恭喜学习HTTP绑定。学习愉快!”;
返回体;
}
但我既没有在URL
localhost:8080/HttpWS/sayhello
上获得Webservice结果,也没有在
WSDL
链接上获得Webservice结果,就像SOAP示例中显示的那样

有谁能帮助我理解如何使用
HTTPBinding

非常感谢。

  • 我尝试使用wsgen工具为上述内容创建WSDL文件 但它给出了一条消息“wsgen无法为其生成WSDL” 类上的非SOAP绑定:/http WbServeImpl“我认为这就是为什么Eclipse也不是 在Web服务启动和运行时生成WSDL。用于HTTP绑定 必须手动编写和发布WSDL。-谢谢

修改标记@WebServiceProvider(portName=“WebServiceImplPort”,serviceName=“WebServiceImplService”,targetNamespace=“”,wsdlLocation=“”)后下面是XML,您好,祝贺您学习HTTP绑定。很高兴学习访问URL。但最终的WSDL是什么仍然没有答案。请帮助。