Java Call WebService Method (axis)

Source: Internet
Author: User

The project needs to call another partner's WebService interface, before using the Sax call method, began to grope this, feel this also quite simple, now the realization of their own process to share to everyone, write bad place, hope everyone do not spray.

The detailed code is as follows:

Package Com.ancs.oa;import Java.util.date;import Javax.xml.namespace.qname;import org.apache.axis2.AxisFault; Import Org.apache.axis2.addressing.endpointreference;import Org.apache.axis2.client.options;import org.apache.axis2.rpc.client.rpcserviceclient;/** * * @ClassName: Messageservice * @Description: Call WebService incoming 5 parameters * @ author [email protected] * @date: December 25, 2014 PM 5:16:21 */public class Messageservice {public static Object Tooamessage (String a,string b,string c,string D) throws axisfault{//using RPC to invoke WebService Rpcserviceclient Client=new RP Cserviceclient (); Options option=client.getoptions (); Specify the URL to call WebService EndpointReference Targetepr =new endpointreference ("Your WebService Address"); Option.setto (TARGETEPR); Specifies the plus method to invoke and the namespace of the WSDL file//http://testqname opaddentry =new QName ("http://webService.oa.ancs.com", "  Docmessageinsert ");  Specify the parameter value of the plus method object[] Opaddentryargs = new object[] {a,b,c,d,new Date ()}; Class object specifying the data type of the plus method return value class[] classes = new class[] {StRing.class}; Call the plus method and output the return value of the method try {return client.invokeblocking (Opaddentry,opaddentryargs, classes) [0];} catch (Axisfault e) {/ /TODO auto-generated catch Blocke.printstacktrace ();} return null;}}


Java Call WebService Method (axis)

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.