zoukankan      html  css  js  c++  java
  • java 调用webservice接口(wsdl)

    进入?wsdl链接,查看方法名、参数、命名空间等信息。

    import org.apache.axiom.om.OMElement;
    import org.apache.axis2.addressing.EndpointReference;
    import org.apache.axis2.client.Options;
    import org.apache.axis2.rpc.client.RPCServiceClient;
    import org.apache.axis2.transport.http.HTTPConstants;

    import javax.xml.namespace.QName; import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.util.ArrayList; import java.util.List; /** * Created by liwj on 2017/6/7. */ public class WebServiceTestReal { private static String url=""; public static void main(String[] args) throws Exception { long startTime=System.currentTimeMillis(); String xml=""; // 使用RPC方式调用WebService RPCServiceClient serviceClient = new RPCServiceClient(); // 指定调用WebService的URL EndpointReference targetEPR = new EndpointReference(url); Options options = serviceClient.getOptions(); //确定目标服务地址 options.setTo(targetEPR); options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, 30000); options.setProperty(HTTPConstants.SO_TIMEOUT, 30000); //避免文件过早结束 options.setProperty(HTTPConstants.CHUNKED, "false"); String fgNamespace=""; String fgLocalPart=""; QName qname = new QName(fgNamespace, fgLocalPart); OMElement element = serviceClient.invokeBlocking(qname, new Object[]{"1","1","lwj",xml}); String retResult = element.getFirstElement().getText(); System.out.println(retResult); long endTime=System.currentTimeMillis(); System.out.println("请求耗时:"+(endTime-startTime) + "ms"); } }
  • 相关阅读:
    depression...
    Childhood is certainly not the happiest time of your time
    我在上海的日子(前言)
    struts国际化的一点尝试
    脚本(js)控制页面输入
    db2和oracle的一些区别
    工作几年是个坎?
    来深圳这半个月
    10年编程无师自通
    初试java mail
  • 原文地址:https://www.cnblogs.com/zuferj115/p/7053019.html
Copyright © 2011-2022 走看看