2017-09-11 27 views
-1

我是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

非常感謝。

+0

修改標籤@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學習。但是由此產生的WSDL還沒有得到答案。請幫忙 。 – summary

回答

0
  • 我試圖使用wsgen工具爲以上 WebService創建WSDL文件。但它給消息「wsgen不能生成WSDL 非SOAP綁定:http://www.w3.org/2004/08/wsdl/http上 com.pkg.WbServeImpl」我認爲這就是爲什麼Eclipse也不是 生成WSDL,而我的web服務啓動並運行。對於HTTP綁定 必須手動編寫和發佈WSDL。 - 由於