找个工具,比如JBUILDERX,都不用自己写代码,一起OK

解决方案 »

  1.   

    使用jbuilderx,创建一个项目,在项目内创建一个Web Service Designer.
    Web Service Designer内地一个下拉框内选择import from url,这样生成一个web service: WSDLService1,鼠标点击该类图的名称部分,右侧弹出框imput wsdl file项输入
    http://www.xxx.com/webservice/service.asmx?WSDL,注意后面增加了?WSDL,这样才是房分定义的文件.build项目,会生成调用示例代码.只要稍微有点基础,一读那几个声明文件就明白了.
    注意一点,.net和java有些类型不相容.微软总喜欢搞些自己的游戏规则.自己既当运动员又当裁判的.
      

  2.   

    package com.myapp;import javax.xml.namespace.QName;
    import javax.xml.rpc.Call;
    import javax.xml.rpc.ParameterMode;
    import javax.xml.rpc.Service;
    import javax.xml.rpc.ServiceFactory;public class DIIClient {
       
        // modified from sun j2ee jaxrpc example

    private static String endpoint = "http://localhost:8080/simple-ws4ee/exactpath/jse";
        private static String qnameService = "HelloWorldService";
        private static String qnamePort = "HelloWorld";    private static String ENCODING_STYLE_PROPERTY =
             "javax.xml.rpc.encodingstyle.namespace.uri"; 
        private static String NS_XSD = 
            "http://www.w3.org/2001/XMLSchema";
        private static String URI_ENCODING =
             "http://schemas.xmlsoap.org/soap/encoding/";    public static void main(String[] args) {        System.out.println("Endpoint address = " + endpoint);        try {
                System.out.println("first1");
                ServiceFactory factory = ServiceFactory.newInstance();
                System.out.println("first2");
                Service service = factory.createService(new QName(qnameService));
                System.out.println("first2");
        
                QName port = new QName(qnamePort);
                System.out.println("first2");
        
                Call call = service.createCall(port);
                System.out.println("first2");
                call.setTargetEndpointAddress(endpoint);
                System.out.println("first2");
        
                call.setProperty(Call.SOAPACTION_USE_PROPERTY, 
                    new Boolean(true));
                System.out.println("first2");
                call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
                System.out.println("first2");
                call.setProperty(ENCODING_STYLE_PROPERTY, URI_ENCODING);
                System.out.println("first3");
                QName QNAME_TYPE_STRING = new QName(NS_XSD, "string");
                System.out.println("first4");
                call.setReturnType(QNAME_TYPE_STRING);
                System.out.println("first5");            call.setOperationName(new QName(endpoint, 
                    "getHelloWorld"));
                System.out.println("first6");
                call.addParameter("String_1", QNAME_TYPE_STRING, 
                    ParameterMode.IN);
                call.addParameter("String_2", QNAME_TYPE_STRING, 
                        ParameterMode.IN);
                call.addParameter("String_3", QNAME_TYPE_STRING, 
                        ParameterMode.IN);
                call.addParameter("String_4", QNAME_TYPE_STRING, 
                        ParameterMode.IN);
                call.addParameter("String_5", QNAME_TYPE_STRING, 
                        ParameterMode.IN);
                System.out.println("first7");
                String[] params = {"dd3","dd3","1","3","5"};            String result = (String)call.invoke(params);
                System.out.println(result);        } catch (Exception ex) {
                System.out.println("ex is "+ex.getMessage());
                ex.printStackTrace();
            }
        }
    }
      

  3.   

    现在用axis提供的wsdl2java,产生了文件,但是遇到.net和java类型无法相互识别的问题,能够给一些建议?()