简体   繁体   English

从浏览器(localhost)调用使用Netbeans和Glassfish创建的WebService方法

[英]Call WebService method created with Netbeans and Glassfish from browser(localhost)

This may sound like a dumb question but i am new to web services. 这听起来像是一个愚蠢的问题,但我是Web服务的新手。

I followed this tutorial and successfully created a Calculator web service up to the point where i created a local client application that consumed the web service method (A java class with main method which calls the web service method). 我遵循了本教程,并成功创建了一个计算器Web服务,直到创建了一个本地客户端应用程序,该应用程序使用了Web服务方法(一个带有main方法的Java类,该类调用了Web服务方法)。

My question now is how can i access this method via my browser and set the parameters there, just get an XML/JSON result. 现在我的问题是如何通过浏览器访问此方法并在那里设置参数,只是获得XML / JSON结果。

My guess is that i am missing something and i have to publish the web service somehow. 我的猜测是我缺少了一些东西,因此我不得不以某种方式发布Web服务。

Any solutions, links are highly appreciated. 任何解决方案,链接均受到高度赞赏。

You have hosted your webservice on glassfish server. 您已在glassfish服务器上托管了Web服务。 Now you want to consume it using internet browser like you did it using test webservice option in net beans. 现在,您要使用Internet浏览器来使用它,就像使用net Bean中的test webservice选项一样。

That means you need to built your own client which runs on web browser. 这意味着您需要构建自己的在Web浏览器上运行的客户端。

You need to built a webpage having two input fields in it and a button as result and whenever you hit this button call your webservice and display it's result. 您需要构建一个包含两个输入字段和一个结果按钮的网页,每当您单击此按钮时,都将调用您的Web服务并显示其结果。 You can follow any simple tutorial of web client or application and again you can deployed it on glassfish or apache server. 您可以按照Web客户端或应用程序的任何简单教程进行操作,然后再次将其部署在glassfish或apache服务器上。

Also you can use soapui (a client to consume web services) to import your wsdl and access its methods, providing inputs and get result in form of soap. 您还可以使用soapui(使用Web服务的客户端)导入wsdl并访问其方法,以soap形式提供输入并获取结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM