Using the SOAP protocol on Android

Source: Internet
Author: User
Tags soap serialization soap ui wsdl
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 application XX relation class. */public class Orderrelation {/** namespace. * * Private final static String Name_space = "Urn:appbackgroundspengine"

    ; /** method.

    * Private final static String method_name = "Appsignright"; The URL of the/** WSDL file.

    * Private final static String Wsdl_url = "http://xxx/services/AppBackgroundSpEngine?wsdl"; 
    /** * <p> * Get the application of XX relationship interface * </p> * @param in XX the relationship between the input parameters * @return XX Relationship Results * * public static Orderrelationresult Fetch (Orderralationinput in) {if (in = = null) {throw new Illeg
        Alargumentexception ("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 Httptransportse (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;
 }
}

Description: The above name Space,method name can be viewed through 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.