wsdl Soap request format for android

时光怂恿深爱的人放手 提交于 2019-12-08 10:44:24

问题


I am trying to access web services from Android using ksoap2. Soap request send from my android emulator is like,

<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<Login xmlns="http://xxx.com/" id="o0" c:root="1">
<MyLoginCredentials i:type="d:anyType">
<Email i:type="d:string">asdf@asd.com</Email>
<Password i:type="d:string">asdf</Password>
</MyLoginCredentials>
</Login>
</v:Body>
</v:Envelope>

but form SoapUI, a successful login request is like,

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:str="http://xxx.com/">
    <soapenv:Header/>
    <soapenv:Body>
        <str:Login>
    <str:MyLoginCredentials>

        <str:Email>asdf@asd.com</str:Email>
        <str:Password>asdf</str:Password>
    </str:MyLoginCredentials>
</str:Login>
    </soapenv:Body>
</soapenv:Envelope>

here is my android code section:

        String NAMESPACE = "http://xxx.com/";
        String METHOD_NAME = "Login";
        String SOAP_ACTION = "http://xxx.com/Login";
        String URL = "http://xxx.tk/service.asmx?wsdl";

        Object results;

        System.setProperty("http.keepAlive", "false");

        SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);


        Request.addProperty("MyLoginCredentials", myLoginCredentials);

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

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.debug = true; 

        String Str = null;
        try
        {
            androidHttpTransport.call(SOAP_ACTION, envelope);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

Please help me to solve the issue. Thanks..


回答1:


Refer below link may be useful for you.

http://codeoncloud.blogspot.in/2012/04/android-web-service-access-tutorial.html

http://codeoncloud.blogspot.in/2012/04/android-403-webservice-access-tutorial.html

http://www.codeproject.com/Articles/112381/Step-by-Step-Method-to-Access-Webservice-from-Andr



来源:https://stackoverflow.com/questions/14064822/wsdl-soap-request-format-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!