Java WebService call example

Source: Internet
Author: User

Download the Axis. jar package online
Put it in the C: // lib directory, a total of 9.

Then, run the following command on the console:
C: \ lib
Java-classpath ".; commons-logging-1.0.4.jar; axis. jar; commons-discovery-0.2.jar; jaxrpc. jar; wsdl4j-1.5.1.jar;
Saaj. jar; activation. jar; mail. jar "org. apache. axis. wsdl. WSDL2Java-o" abcdefg"
Http: // 10.10.10.111/WebService/ManageUsersService. asmx? Wsdl
The corresponding java classes will be generated under the corresponding directory, and these classes will be copied to your project directory,
Add the nine packages of Axis to the project, and you can call WebService like a normal class.
Call method: MsgService MS = new MsgServiceLocator ();
MsgServiceSoap msgServer = ms. getMsgServiceSoap ();

String strSystemID = "ffffffffffffffffffffffffffff"; // UAP System ID, 32-bit.
String strAccessUserName = "aaa"; // you need to apply
String strAccessPassWord = "aaa"; // you need to apply
String strSMSurl = http: // */MsgService. asmx; // SMS webService address

SendMMSIn pIn = new SendMMSIn (); // Message Parameter class
PIn. setFromUserMobile (""); // the sender's mobile phone
PIn. setcancelist (new String [] {"13510985723"}); // receiving mobile phone list
SimpleDateFormat bartDateFormat = new SimpleDateFormat ("yyyy-MM-dd HH: mm: ss ");
PIn. setSendTime (bartDateFormat. format (new Date (System. currentTimeMillis (); // sending time

// Add MMS content-Text
MMcontent mm1 = new MMcontent ();
Mm1.setCharSet ("UTF-8 ");
String mm1Content = "use WS to send MMs! ";
Mm1.setContentBytes (mm1Content. getBytes ("UTF-8 "));
Mm1.setContentID ("text1.txt ");
Mm1.setContentType (MMcontentType. TEXT );

// Add MMS content-Image
MMcontent mm2 = new MMcontent ();
Mm2.setCharSet ("UTF-8 ");
Byte [] bytes = getByteFromFile ("F: \ mmsjp.jpg ");
Mm2.setContentBytes (bytes );
Mm2.setContentType (MMcontentType. JPEG );
Mm2.setContentID ("mmsjp.jpg ");

MMcontent [] mmcs = new MMcontent [] {mm1, mm2 };
PIn. setMmsContents (mmcs );

SendMMSOutHolder pOut = new SendMMSOutHolder ();
SXTCallResultHolder result = new SXTCallResultHolder ();
MsgServer. sendMMS (strSystemID, strAccessUserName, strAccessPassWord, pIn, result, pOut );

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.