我知道怎么用Java函数来创建wsdl文件,就是想问一下有了wsdl文件,怎么用Java函数(类、方法)去调用它?怎么用jsp调用这个wsdl?期望各位大侠能做一下指导! 
很急!!

解决方案 »

  1.   

    对wsdl不了解,顶,学习一下!
      

  2.   

    wsdl据说是开发语言之间的翻译,很牛的
      

  3.   

    导入axis的八个包:
    axis.jar
    commons-discovery.jar
    commons-logging.jar
    jaxrpc.jar
    saaj.jar
    wsdl4j.jar 
    axis-ant.jar
    log4j-1.2.8.jar
    开发客户端程序。开发客户端程序的项目中要加入axis.jar包。
    文件:TestWebService.java
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import org.apache.axis.encoding.XMLType;
    public class TestWebService {
    public static void main(String[] args) {
            try {
                //还记得刚才的那个WebService的services.xml中的namespace吗?
                String endpoint = "http://localhost:8080/uum/services/Hello.jws?wsdl";
                Service service = new Service();
                Call call = (Call) service.createCall();
                call.setTargetEndpointAddress(new java.net.URL(endpoint));
                call.setOperationName("GetName"); // 这里是的Hello类中的方法名(注意大小写)
                call.setReturnType(XMLType.XSD_STRING); // 返回值类型。
                call.addParameter("name",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
                String[] str= {"张三"};
                Object[] o = str;
              //Object[] o =null;//如果你的方法中没有参数,那么就这样写吧。
                String hello = (String) call.invoke(o);// 做方法执行。
                System.out.println(hello);
            } catch (Exception e) {
                System.err.println(e.toString());
            }
        }
    }
    执行这段代码,将会在命令行中输出 “hello 张三”,表示测试成功。
    Axis下载地址为http://ws.apache.org/axis/
      

  4.   

    用Axis开发Web Service,我刚用过,很好用的,好好学学吧!
      

  5.   

    这个是WEB SERVISE 的调用,你的IDE能自动生成代码的,然后再调用
      

  6.   

    用代码怎么调用呢创建了Service ser=new Service()
    Cell c=ser.creatCell();
    c.setTargetEndpointAddress("wsdl的地址");
    怎么知道它的返回值呢。
      

  7.   

    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
    definition = wsdlReader.readWSDL(wsdlPath);
    Map services = definition.getServices();
    Types types = (TypesImpl) definition.getTypes();
    while(portsIter.hasNext()){
    PortImpl port = (PortImpl) portsIter.next();
    List bindingOperations = port.getBinding().getBindingOperations();
    if(bindingOperations.size() ==1 ){
       CreateWSDLOperation((BindingOperation) bindingOperations.get(0));

       wsdlOperation.setSoapAddress(getSopaAddress(port));
    }
    private String getSopaAddress(Port port){
    String soapAddress = "";
    List address = port.getExtensibilityElements();
    if (port.getExtensibilityElements().size() == 1) {
    SOAPAddress element = (SOAPAddress) address
    .get(0);
    soapAddress = element.getLocationURI() ;
    }
    return soapAddress ;
      
    }