Java calls. net web service

Source: Internet
Author: User

Code:

 

Import javax. xml. namespace. QName;
Import org. apache. axis. client. Call;
Import org. apache. axis. client. Service;

Public class IPreventIndulge {
Public boolean getValidateInfo (String UUid ){
Try {
String endpoint = "http://game.qidian.com/RemoteWebService/IPreventIndulge.asmx ";
// Create a service call)
Service service = new Service ();
Call call = (Call) service. createCall (); // create a call object through the service
// Set the URL of the service
Call. setTargetEndpointAddress (new java.net. URL (endpoint ));
Call. setUseSOAPAction (true );
Call. setSOAPActionURI ("http://tempuri.org/GetIndulgeInfo"); // This should also be noted that it is to Add the method to be called Add, otherwise it will also report an error
Call. setOperationName (new QName ("http://tempuri.org/", "GetIndulgeInfo "));
// GetIndulgeInfo method name
Call. addParameter (new QName ("http://tempuri.org/", "idType "),
Org. apache. axis. encoding. XMLType. XSD_STRING,
Javax. xml. rpc. ParameterMode. IN );
Call. addParameter (new QName ("http://tempuri.org/", "UUId "),
Org. apache. axis. encoding. XMLType. XSD_STRING,
Javax. xml. rpc. ParameterMode. IN );

Call. setReturnType (org. apache. axis. encoding. XMLType. SOAP_STRING); // type of the returned Parameter


// The Object array encapsulates parameters. The parameter is "This is Test! ", Call processService (String arg)
String ret = (String) call. invoke (new Object [] {UUid, "0 "});
System. out. println (ret );
} Catch (Exception e ){
E. printStackTrace ();
}
Return false;
}
Public static void main (String [] args ){
New IPreventIndulge (). getValidateInfo ("411668171 ");
}
}

 

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.