为 Web 服务创建客户端 [英] Creating client for web service

查看:28
本文介绍了为 Web 服务创建客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 jboss 服务器中部署了一个简单的 hello 服务.我可以查看 wsdl 文件.有人可以帮我处理客户端吗?我的意思是如何访问此服务?有什么办法可以从网络浏览器访问吗?部署的方法是

I have deployed a simple hello service in jboss server. I can view the wsdl file. Can someone help me with the client side. I mean how to access this service? Is there any way to access from web browser? Method deployed is

@WebMethod
public String greet( @WebParam(name = "name")
String name )
    {
   return "Hello" + name;
    }

推荐答案

尝试知道访问您刚刚公开的服务的 wsdl url 是什么.它很可能类似于http://localhost: < port-number >/ems-ejb/?wsdl"

Try to know what is the wsdl url to access the service which you have just exposed. It might most probably be something like "http://localhost: < port-number >/ems-ejb/?wsdl"

如果您在浏览器中输入相同的内容,您应该可以看到 wsdl 文件(页面充满了 xml 标签).

If you type the same in the browser, you should be able to see the wsdl file (page with full of xml tags).

完成后,按照此处提供的步骤

生成客户端存根后如何调用方法的示例

Example on how to call the method once client stub is generated

String endpoint = "your wsdl url";
GreetImplServiceLocator objGreetImplServiceLocator = new GreetImplServiceLocator();
java.net.URL url = new java.net.URL(endpoint);
GreetIntf objGreetIntf = objGreetImplServiceLocator.getFaultImplPort(url);
 String greetings=objFaultIntf.greet("stackoverflow");

这篇关于为 Web 服务创建客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆