Home>Article>Java> How SpringBoot uses axis to call the webservice interface

How SpringBoot uses axis to call the webservice interface

王林
王林 forward
2023-05-11 13:28:06 2064browse

WebService

Definition

How SpringBoot uses axis to call the webservice interface

Personal understanding

Through Du Niang and other methods, my personal understanding is that it is a disguised soap protocol plus xml process Single processing,

Practice

webservice common sense

A webservice interface publishing address is often similar:

  • qq Online verification interface:

www.webxml.com.cn/webservices…

  • Other testable interfaces:

emailEmail address interface: www.webxml.com.cn/WebServices…

National weather conditions interface:

www.webxml.com.cn/WebServices…

qq Take the online interface verification interface as an example

Add after the interface:/wsdlwww.webxml.com.cn/webservices…

Access and view and find the one defined in the figure below Content: Pay attention to using the associated key to find the corresponding necessary parameters.

How SpringBoot uses axis to call the webservice interface

maven uses axis

Apply dependencies (cannot be missing and required)

  org.apache.axis axis 1.4    wsdl4j wsdl4j 1.6.2     javax.xml jaxrpc-api 1.1     commons-discovery commons-discovery 0.2 

Code (paste available)

@Test public void testWebService() { try { //wsdl地址 String endpoint = "http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx"; //命名空间 String namespace = "http://WebXml.com.cn/"; //服务名 String serviceName = "qqOnlineWebService"; //方法名 String methodName = "qqCheckOnline"; //soapAction String soapAction = "http://WebXml.com.cn/qqCheckOnline"; Service service = new Service(); Call call = (Call) service.createCall(); //设置响应超时 call.setTimeout(3000); //设置地址 call.setTargetEndpointAddress(new java.net.URL(endpoint)); //设置方法名 call.setOperationName(new QName(namespace, methodName)); //设置参数 call.addParameter(new QName(namespace, "qqCode") , org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); //设置返回类型 call.setReturnType(XMLType.XSD_SCHEMA); //启用soap call.setUseSOAPAction(true); //设置soapAction call.setSOAPActionURI(soapAction); //设置服务名 SOAPService soapService = new SOAPService(); soapService.setName(serviceName); call.setSOAPService(soapService); Schema result = (Schema) call.invoke(new Object[]{"xxxxx"}); for (int i = 0; i < result.get_any().length; i++) { System.out.println(result.get_any()[i]); } } catch (Exception e) { log.error("ddd", e); } }

Regarding the above code, let me complain here. There are actually many examples of this on the Internet, but problems will occur when actually calling it. Note:

  • Setting parameters

How SpringBoot uses axis to call the webservice interface

  • Get the results

How SpringBoot uses axis to call the webservice interface

##xxxx needs to fill in the real QQ number

The above is the detailed content of How SpringBoot uses axis to call the webservice interface. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete