Java invoke WebService (ASMX) example (actual application) __java

Source: Internet
Author: User
Package com.segsec.gisap.webservice;

Import Java.util.Vector;

Import Javax.xml.namespace.QName;
Import Org.apache.axis.client.Call;
Import Org.apache.axis.client.Service;

Import Org.apache.axis.encoding.XMLType; public class Lbsrescue {private String url = "Http://IP address/lbsrescue.asmx";//provide interface address private string soapaction = "http ://www.***.net:7005/";
		Domain name, which is the public lbsrescue () defined in server () {String city = "Beijing";
		Service service = new service ();
			try {Call call = (call) Service.createcall ();
			Call.settargetendpointaddress (New Java.net.URL (URL));
			Call.getmessagecontext (). Setusername ("YGBX");//user name in axis.
			Call.getmessagecontext (). SetPassword ("5ky3xhfxynnhptwrhvdycq==");//Password Call.setusesoapaction (true);
			Call.setsoapactionuri (SOAPAction + "sendlist"); Call.setoperationname (New QName (SOAPAction, "sendlist")); Set which method to invoke Call.addparameter (new QName (SOAPAction, "CompanyID"),//Set parameters to pass Org.apache.axis.encoding.XMLT Ype. Xsd_string, JAVAX.XMl.rpc.parametermode.in); 
					Call.addparameter (New QName (SOAPAction, "companypwd"),//Set parameters to pass Org.apache.axis.encoding.XMLType.XSD_STRING,
			Javax.xml.rpc.ParameterMode.IN);
					Call.addparameter (New QName (SOAPAction, "mobile"),//Set parameters to pass Org.apache.axis.encoding.XMLType.XSD_STRING,
			Javax.xml.rpc.ParameterMode.IN);
					Call.addparameter (New QName (SOAPAction, "flag"),//Set parameters to pass Org.apache.axis.encoding.XMLType.XSD_STRING,
			
			Javax.xml.rpc.ParameterMode.IN); Call.setreturntype (xmltype.xsd_string); The data type to return (custom type)//Call.setreturntype (Org.apache.axis.encoding.XMLType.XSD_STRING);//(standard type) call.setusesoapact
			Ion (TRUE);

			Call.setsoapactionuri (SOAPAction + "sendlist"); string s = (string) call.invoke (new object[] {"YGBX", "pfao/msenzv8lchxtpa9yw==", "15910510352", 1});//calling method and passing parameter System.

		OUT.PRINTLN ("Registered mobile phone:" +s);
		catch (Exception ex) {ex.printstacktrace (); } public static void Main (String args[]) {LbsrescuE LR = new Lbsrescue ();
 }

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.