进入?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"); } }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2021-11-16
  • 2021-05-01
  • 2021-12-29
  • 2022-01-07
猜你喜欢
  • 2021-11-20
  • 2022-12-23
  • 2021-04-11
  • 2022-12-23
  • 2021-10-03
  • 2022-02-01
  • 2021-09-23
相关资源
相似解决方案