简体   繁体   English

如何在Android中使用KSOAP2发送此SOAP请求

[英]How can I send this SOAP request using KSOAP2 in Android

I am very new to SOAP and Android. 我是SOAP和Android的新手。 Can some one please help me to build an SOAP request to send the following request. 有人可以帮我建立一个SOAP请求来发送以下请求吗?

SOAPAction: http://api.example.com/application

Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns="http://api.example.com/registration/v3.1">
<soapenv:Header>
<ns0:appCredentials ns0:name="your-account-name" ns0:password="mypassword" ns0:targetAccountName="vvz"
xmlns:ns0="http://services.example.com/application/types/1.0"/>
</soapenv:Header>
<soapenv:Body>
<ns:identityPoint_identify_request>
<ns:identification type="email-password">
<ns:email>
<ns:address>action@vvz.com</ns:address>
</ns:email>
<ns:password>actionbar123</ns:password>
</ns:identification></ns:identityPoint_identify_request>
</soapenv:Body>
</soapenv:Envelope>

Thank YOu 谢谢

i recommend you use the KSOAP2 java library. 我建议您使用KSOAP2 Java库。 its very simple and great lib. 它非常简单而且很棒。 im using it for a long time. 即时通讯使用了很长时间。 you can build any soap object you want in a simple java code. 您可以使用简单的Java代码构建所需的任何soap对象。

here: http://simpligility.github.io/ksoap2-android/index.html 此处: http : //simpligility.github.io/ksoap2-android/index.html

A simple Example: 一个简单的例子:

private static final String SOAP_ACTION = "http://tempuri.org/GetInteger2";
private static final String METHOD_NAME = "GetInteger2";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://10.0.22:4711/Service1.asmx";

public int GetInteger2() throws IOException, XmlPullParserException {
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

    PropertyInfo pi = new PropertyInfo();
    pi.setName("i");
    pi.setValue(123);
    request.addProperty(pi);

    SoapSerializationEnvelope envelope =
        new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);

    AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
    androidHttpTransport.call(SOAP_ACTION, envelope);

    SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
    return Integer.parseInt(result.toString());
}

have fun! 玩得开心!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM