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

查看:119
本文介绍了创建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 :<端口号>/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天全站免登陆