Android WSDL/SOAP service client

后端 未结 7 2185
北恋
北恋 2020-11-30 22:53

I have some web services that uses WSDL/SOAP for communication. Specifically, I am using PHP and Nusoap to make them. How can I use these web services on Android? I am going

7条回答
  •  青春惊慌失措
    2020-11-30 23:18

    I have just completed a android App about wsdl,i have some tips to append:

    1.the most important resource is www.wsdl2code.com

    2.you can take you username and password with header, which encoded with Base64,such as :

            String USERNAME = "yourUsername";
        String PASSWORD = "yourPassWord";
        StringBuffer auth = new StringBuffer(USERNAME);
        auth.append(':').append(PASSWORD);
        byte[] raw = auth.toString().getBytes();
        auth.setLength(0);
        auth.append("Basic ");
        org.kobjects.base64.Base64.encode(raw, 0, raw.length, auth);
        List headers = new ArrayList();
        headers.add(new HeaderProperty("Authorization", auth.toString())); // "Basic V1M6"));
    
        Vectordianzhan response = bydWs.getDianzhans(headers);
    

    3.somethimes,you are not sure either ANDROID code or webserver is wrong, then debug is important.in the sample , catching "XmlPullParserException" ,log "requestDump" and "responseDump"in the exception.additionally, you should catch the IP package with adb.

        try {
        Logg.i(TAG, "2  ");
        Object response = androidHttpTransport.call(SOAP_ACTION, envelope, headers); 
        Logg.i(TAG, "requestDump: " + androidHttpTransport.requestDump);
        Logg.i(TAG, "responseDump: "+ androidHttpTransport.responseDump);
        Logg.i(TAG, "3");
    } catch (IOException e) {
        Logg.i(TAG, "IOException");
    } 
    catch (XmlPullParserException e) {
         Logg.i(TAG, "requestDump: " + androidHttpTransport.requestDump);
         Logg.i(TAG, "responseDump: "+ androidHttpTransport.responseDump);
         Logg.i(TAG, "XmlPullParserException");
         e.printStackTrace();
    }
    

提交回复
热议问题