Java call Webservcie, self-test available

Source: Internet
Author: User
Tags wsdl

The first time with Java tune Webervice, online read a lot of blogs, can use a few, integrated several blogs, finally successfully called.

Package com.casco.action;
Import Org.apache.axis.client.Call;
Import Org.apache.axis.client.Service;
Import Javax.xml.namespace.QName;

public class Syncprojectdata {

public void Syncproject (String projectno)
{

}

public static void Main (string[] args) {
try {
String endpoint = "XXXX?WSDL";
Directly referencing a remote WSDL file
Here are the routines.
Service service = new service ();
Call Call Service.createcall ();
Call.settargetendpointaddress (endpoint);
Call.setoperationname (New QName ("http://tempuri.org/", "getprojectbycondition")); Interface name described in WSDL
Call.addparameter (New QName ("http://tempuri.org/", "condition"),
Org.apache.axis.encoding.XMLType.XSD_STRING, Javax.xml.rpc.ParameterMode.IN);//Parameters of the interface
Call.setusesoapaction (TRUE);
Call.setreturntype (Org.apache.axis.encoding.XMLType.SOAP_STRING); Returns the type of the parameter
Call.setsoapactionuri ("Http://tempuri.org/GetProjectByCondition"); This also should be noted is to add the method to call Getprojectbycondition, otherwise it will error
String temp = "A0117032"; The value of the parameter
String result = (string) call.invoke (new object[] {temp});
Pass a parameter to the method, and call the method
SYSTEM.OUT.PRINTLN ("result is" + result);
} catch (Exception e) {
System.err.println (E.tostring ());
}

}
}

Java call Webservcie, self-test available

Related Article

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.