Use the Soap protocol on android

Source: Internet
Author: User
Tags soap ui

Package XXX; import org. ksoap2.SoapEnvelope; import org. ksoap2.serialization. soapObject; import org. ksoap2.serialization. soapSerializationEnvelope; import org. ksoap2.transport. httpTransportSE; import org. xmlpull. v1.XmlPullParserException; import java. io. IOException; import java.net. inetSocketAddress;/*** get the application XX link class. */public class OrderRelation {/** namespace. */private final static String NAME_SPACE = "urn: AppBackgroundSpEngine ";/** method. */private final static String METHOD_NAME = "appSignRight";/** URL of the WSDL file. */private final static String WSDL_URL = "http: // xxx/services/AppBackgroundSpEngine? Wsdl "; /*** <p> * obtain the XX Link Interface of the application * </p> ** @ param in XX link input parameter * @ return XX link result */public static OrderRelationResult fetch (OrderRalationInput in) {if (in = null) {throw new IllegalArgumentException ("Input parameter is null");} final OrderRelationResult result = new OrderRelationResult (); final SoapObject so = new SoapObject (NAME_SPACE, METHOD_NAME); so. addProperty ("transId", in. getTransId (); so. AddProperty ("mobile", in. getUserId (); so. addProperty ("imsi", in. getImsi (); so. addProperty ("appId", in. getAppId (); so. addProperty ("timeStamp", in. getTimeStamp (); so. addProperty ("clientType", in. getClientType (); so. addProperty ("sig", in. getSig (); final SoapSerializationEnvelope se = new SoapSerializationEnvelope (SoapEnvelope. VER11); se. bodyOut = so; final HttpTransportSE ht = new HttpTransport SE (WSDL_URL); try {ht. call (NAME_SPACE, se); final SoapObject response = (SoapObject) se. bodyIn; if (response! = Null) {System. out. println ("response:" + response); result. setResultCode (Integer. parseInt (response. getPropertyAsString ("resultCode"); result. setTransId (response. getPropertyAsString ("transId"); result. setType (Integer. parseInt (response. getPropertyAsString ("type");} catch (IOException e) {e. printStackTrace (); return null;} catch (XmlPullParserException e) {e. printStackTrace (); return null;} catch (NullPointerException e) {e. printStackTrace (); return null;} return result ;}}

Note: The above name space and method name can be viewed using the soap UI tool.

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.