跪求高人:发布web service如何让网络上其他机器也能访问?
我先说一下前面已经完成的工作:
1、say hello服务端程序:
public class HelloServiceClass {
public String helloServiceFunc(String name){
return "Hello,"+name;
}
}
发布该服务后在自己机器上的浏览器中输入:
http://localhost:8080/HelloService/wsdl/HelloServiceClass.wsdl
可以查看到wsdl文件;
2、客户端程序如下:
package mypack;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
public class HelloClient
{
public static void main(String[] args){
try{
String username="Guest";
if(args.length!=0)username=args[0];
String endpoint="http://localhost:8080/HelloService/services/HelloServiceClass";
Service service=new Service();
Call call=(Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("urn:HelloServiceClass","helloServiceFunc"));
String ret=(String)call.invoke(new Object[]{username});
System.out.println(ret);
}catch(Exception e){
e.printStackTrace();
}
}
}
这时候也可以访问所发布的服务,得到返回值“Hello,Guest”
但在别的机器上建立客户端时问题却来了:
我只是把endpoint那段代码改为:
endpoint="http://发布服务的IP:8080/HelloService/services/HelloServiceClass";
或endpoint="http://发布服务的IP/HelloService/services/HelloServiceClass";
却没法访问这个服务,查看服务的wsdl文件也说无法访问。(两台电脑都是可以上网的)
搞了一个下午都不晓得怎么回事,查资料也查不到,快急死了~~求救做过这方面工作的朋友,我想在别的机器上也能访问该服务该怎么做呢?是不是还要手动把服务发布到UDDI上还是别的什么?我是个初学者,希望各位大虾能不吝赐教,在此拜谢了!