In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how Java calls the.asmx interface of webservice. The content of the article is of high quality, so Xiaobian shares it with you as a reference. I hope you have a certain understanding of related knowledge after reading this article.
preface
Contact a webservice interface ending in.asmx and decide to write it down for memory gain.
I. Interface type
interfaces terminated with.asmx
Example: Interface address: http://IP address/xxx/service/xxx/xxxx.asmx Method Name: Test Parameter type: string II. Use Step 1. Access method
The code is (example):
Controller class:
String s = clientUtil.test("http://IP address/xxx/service/xxx/xxxx.asmx", "test","test");
Call class:
public static String test(String Url, String methodName, String str) throws Exception { String ref = null; // webService link address String url = Url; //Get the domain name address defined by server String soapaction = "http://tempuri.org/"; Service service = new Service(); try { Call call = (Call) service.createCall(); call.setTargetEndpointAddress(url); //Set which method to call call.setOperationName(new QName(soapaction, methodName)); //Set parameter name to pass call.addParameter(new QName(soapaction,"str"),org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); //provide standard type addParameter must have setReturnType call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING); call.setUseSOAPAction(true); call.setSOAPActionURI(soapaction + methodName); //Call method and pass parameters ref = (String) call.invoke(new Object[]{str}); return ref; } catch (Exception e) { e.printStackTrace(); } return ref; }2. Imported maven
As follows:
javax.activation activation 1.1.1 org.apache.axis axis 1.4 axis axis-jaxrpc 1.4 About Java how to call the webservice.asmx interface to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.