网络服务测试
我使用 JAX-WS 制作了 Web 服务。现在我想使用网络浏览器进行测试,但出现错误。有人可以帮我解释一下吗?
我的服务类:
package another;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
@WebService(name = "WebService")
public class WebServiceTest {
public String sayHello(String name) {
return "Hello : " + name;
}
public static void main(String[] args) {
WebServiceTest server = new WebServiceTest();
Endpoint endpoint = Endpoint.publish(
"http://localhost:9191/webServiceTest", server);
}
}
我将此类作为简单的 Java 程序运行。
我可以在浏览器中的 http://localhost:9191/webServiceTest?wsdl
中看到 WSDL。
我尝试使用 URL http://localhost:9191/webServiceTest?sayHello?name=MKGandhi
调用它,但我没有得到任何结果。
这里有什么问题吗?
I made web services using JAX-WS. Now I want to test using a web browser, but I am getting an error. Can somebody explain me please help.
My Service class:
package another;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
@WebService(name = "WebService")
public class WebServiceTest {
public String sayHello(String name) {
return "Hello : " + name;
}
public static void main(String[] args) {
WebServiceTest server = new WebServiceTest();
Endpoint endpoint = Endpoint.publish(
"http://localhost:9191/webServiceTest", server);
}
}
I run this class as simple Java program.
And I can see the WSDL in my browser at http://localhost:9191/webServiceTest?wsdl
.
And I am trying to call this using the URL http://localhost:9191/webServiceTest?sayHello?name=MKGandhi
, but I am not getting any result.
What is wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我无法告诉你为什么无法在浏览器中测试它。
但至少我可以告诉你如何从你的代码中测试它,因为你的网络服务可以工作:
I can't tell you why it is not possible to test it in browser.
But at least I can tell you how to test it from your code, cause your webservice works:
您尝试使用 url
http://localhost:9191/webServiceTest?sayHello?name=MKGandhi
测试您的 Web 服务只需尝试这个 url
http://localhost:9191/webServiceTest/sayHello ?名称=MK甘地
它应该可以正常工作:)
You try and test your webservice by using the url
http://localhost:9191/webServiceTest?sayHello?name=MKGandhi
Just try this url
http://localhost:9191/webServiceTest/sayHello?name=MKGandhi
it should work fine :)
在您的网址“http://localhost:9191/webServiceTest?sayHello?name=MKGandhi”
尝试通过您的IP 地址更改本地主机。
示例:“http://198.251.234.45:9191/webServiceTest?sayHello?name=MKGandhi”
in your url "http://localhost:9191/webServiceTest?sayHello?name=MKGandhi"
try changing the localhost by your ip address.
example : "http://198.251.234.45:9191/webServiceTest?sayHello?name=MKGandhi"