当前位置 : 主页 > 网页制作 > Nodejs >

Axis调用WebService

来源:互联网 收集:自由互联 发布时间:2021-06-24
jar包: activation.jar axis.jar commons-discovery-0.2.jar commons-logging-1.0.4.jar jaxrpc.jar wsdl4j-1.5.1.jar jar包下载地址:http://mirrors.hust.edu.cn/apache/axis/axis/java/1.4/ -------- --------------------------------------- --

jar包:

activation.jar

axis.jar

commons-discovery-0.2.jar

commons-logging-1.0.4.jar

jaxrpc.jar

wsdl4j-1.5.1.jar

jar包下载地址:http://mirrors.hust.edu.cn/apache/axis/axis/java/1.4/

-----------------------------------------------------------默默无闻的分割线-----------------------------------------------------------

webService调用:

import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;


public void getMobileCodeDBInfo() {

    try {

       String url = "http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx";
//命名空间
       String soapaction = "http://WebXml.com.cn/";
       Service service = new Service();
       Call call = (Call) service.createCall();

       call.setTargetEndpointAddress(url);
       call.setOperationName(new QName(soapaction, "getDatabaseInfo"));
       call.setReturnType(new QName(soapaction, "getDatabaseInfo"),Vector.class);
       call.setUseSOAPAction(true);
       call.setSOAPActionURI(soapaction + "getDatabaseInfo");

       Vector v = (Vector) call.invoke(new Object[] {});

        for (int i = 0; i < v.size(); i++) {

            System.out.println(v.get(i));
         }

    } catch (Exception ex) {

          ex.printStackTrace();       }}

网友评论