Java calls the WebService axis implementation

Source: Internet
Author: User
Tags soap

ImportOrg.apache.axis.client.Call;ImportOrg.apache.axis.client.Service;/*** @ClassName: Testaxis * @Description: TODO (Describe the role of this class) *@authorroy_70* @date April 18, 2017 morning 9:16:26 **/  Public classTestaxis { Public Static voidMain (string []args) {string Inconditions= "<?xml version=\" 1.0\ "encoding=\" utf-8\ "?><rows><info><sbm>*</sbm></info> <ROW><GMSFHM> Citizenship number </GMSFHM><XM> name </XM></ROW><ROW><GMSFHM> 110101******</gmsfhm><xm> Li Yu </XM><FSD>100600</FSD><YWLX> Personal Loans </YWLX> </ROW><ROW><GMSFHM>3624221952123***</GMSFHM><XM> Lee Smell </xm><fsd>100600 </FSD><YWLX> Personal Loans </YWLX></ROW><ROW><GMSFHM>1234********</GMSFHM>< Xm> Wang Long </XM><FSD>100600</FSD><YWLX> bank account opening &LT;/YWLX&GT;&LT;/ROW&GT;&LT;ROW&GT;&LT;GMSFHM >110101******</GMSFHM><XM></XM><FSD>100600</FSD><YWLX> Personal car Loan </YWLX> </row><row><gmsfhm>110101******</gmsfhm><xm></xm><fsd>100600</fsd ><ywlx></ywlx></row><row><gmsfhm>230602***</gmsfhm><xm></xm ><fsd>100600</fsd><ywlx> Personal car Loan </YWLX></ROW></ROWS> " ; String Inlicense= "********"; Try{                       //Call WebService AddressString url = "Https://www.****.com/services/nciicservices"; //Call Method NameString method= "Nciiccheck"; Service Service=NewService (); //Create a Call object from a serviceCall call =(call) Service.createcall (); //Set up service addressCall.settargetendpointaddress (NewJava.net.URL (URL)); //setting the Calling methodCall.setoperationname (method); Call.setusesoapaction (true); //add a few more parameters to the method//Inlicense is the parameter name, xsd_string is the parameter type, in represents the incomingCall.addparameter ("Inlicense", org.apache.axis.encoding.xmltype.xsd_string,javax.xml.rpc.parametermode.in); Call.addparameter ("Inconditions", org.apache.axis.encoding.xmltype.xsd_string,javax.xml.rpc.parametermode.in); //Set return typeCall.setreturntype (Org.apache.axis.encoding.XMLType.XSD_STRING); Object ret=NULL; Try{                    //using the invoke Invoke method, the object data is placed in the passed parameter valueret = Call.invoke (Newobject[] {inlicense,inconditions}); }Catch(Exception e) {e.printstacktrace (); }                //Output SOAP Request messageSystem.out.println ("--soap Request:" +Call.getmessagecontext (). Getrequestmessage (). getsoappartasstring ()); //output SOAP return messageSystem.out.println ("--soap Response:" +call.getresponsemessage (). getsoappartasstring ()); //Output return informationSystem.out.println ("result===" +ret.tostring ()); }Catch(Exception e) {e.printstacktrace (); }    }   }

The following is the output result information:

--soap Request: <?xml version= "1.0" encoding= "UTF-8"? ><soapenv:envelope xmlns:soapenv= "/http/ schemas.xmlsoap.org/soap/envelope/"xmlns:xsd=" Http://www.w3.org/2001/XMLSchema "xmlns:xsi=" http://www.w3.org/ 2001/xmlschema-instance "><soapenv:body><nciiccheck soapenv:encodingstyle="/http schemas.xmlsoap.org/soap/encoding/"><inlicense xsi:type=" xsd:string ">*****</inLicense>< Inconditions xsi:type= "Xsd:string" >*****</inconditions></nciiccheck></soapenv:body></ Soapenv:envelope>--soap Response: <?xml version= "1.0" encoding= "UTF-8"? ><soap:envelope xmlns:soap= "http ://schemas.xmlsoap.org/soap/envelope/"xmlns:xsd=" Http://www.w3.org/2001/XMLSchema "xmlns:xsi=" http://www.w3.org /2001/xmlschema-instance "><soap:body><ns1:nciiccheckresponse xmlns:ns1=" https://api.nciic.org.cn/ Nciicservices "&GT;&LT;NS1:OUT&GT;&AMP;LT;? XML version=&quot;1.0&quot; encoding=&quot; Utf-8&quot;? &gt;&lt; RESPONSE Errorcode=&quot;-72&quot; code=&quot;0&quot; countrows=&quot;1&quot;&gt;&lt; rows&gt;&lt; row&gt;&lt; errorcode&gt;-72&lt;/errorcode&gt;&lt; errormsg&gt;ip& #x5730;& #x5740;& #x53D7;& #x9650; &lt;/errormsg&gt;&lt;/row&gt ; &lt;/rows&gt;&lt;/response&gt;</ns1:out></ns1:nciiccheckresponse></soap:body ></soap:envelope>result===<?xml version= "1.0" encoding= "UTF-8"? ><response errorcode= " -72" code= " 0 "countrows=" 1 "&GT;&LT;ROWS&GT;&LT;ROW&GT;&LT;ERRORCODE&GT;-72&LT;/ERRORCODE&GT;&LT;ERRORMSG&GT;IP address limited </ Errormsg></row></rows></response>

Java calls the WebService axis implementation

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.