如何创建ksoap2请求对象

时间:2013-07-11 06:27:54

标签: android soap android-ksoap2

我正在努力为跟随肥皂请求创建SOAP Request

    <?xml version="1.0"?>
        <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Header/><SOAP-ENV:Body><ns1:Authenticate xmlns:ns1="urn:Login" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <msgstr xsi:type="xsd:string"><Message messageid="0">
              <Entity name="REF_LOGIN">
                <Property name="login_cd" value="ABC" type="STRING"/>
                <Property name="password" value="ABC" type="STRING"/>
                <Property name="machine_name" value="iPhone Simulator" type="STRING"/>
                <Property name="language_code" value="en" type="STRING"/&gt;
                <Property name="client_version_cd" value="XL7.11" type="STRING"/>
              </Entity>
            </Message></msgstr></ns1:Authenticate></SOAP-ENV:Body></SOAP-ENV:Envelope>

1 个答案:

答案 0 :(得分:0)

  

希望这个帮助:我在这里发布了我的代码:替换你的   适当的价值

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        PropertyInfo propInfo1 = new PropertyInfo();
        propInfo1.setName("Input_if_any");
        propInfo1.setValue(1);
        propInfo1.setType(int.class);
        request.addProperty(propInfo1);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        envelope.dotNet = true; // put this only if the web service is .NET one
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        try {
            androidHttpTransport.call(SOAP_ACTION, envelope);
            // SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
            Object response1 = envelope.getResponse();
            SoapObject response = (SoapObject) response1;

            Log.i("myApp", response1.toString());
            if (response1.toString().equalsIgnoreCase("true")) {
                result = true;
            }
相关问题