简体   繁体   中英

Android wshttpbinding support

I want to connect to a Soap 1.2 web service but as I understand it, android doesnt support wshttpbindings. So I tried the ksoap2 lib which should be able to send a correct soap action.

        SoapObject request = new SoapObject(NAMESPACE, SOAP_METHOD);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
        envelope.implicitTypes = true;
        envelope.dotNet = true;
        envelope.headerOut = SoapUtils.buildHeader(SSL_URL, SOAP_ACTION);

I even tried to write the header but Im just not sure what Tags are really needed for a wshttpbinding. Does anyone know how to use the wshttpbinding under android? I already took a look at the other questions but nothing worked. Please help.

Better try with basicHttpBinding. The wsHttpBinding uses some advanced message security (depending on your settings) which is not supported in Android. Transport security (ssl) will be easier.

I have connected to the wsdl service. The clue is that the service needs a primary request which returns a SecurityContextToken. This token is needed for additional request. The first soap envelope looks like this:

SecurityTokenRequest

If I send this soap envelope to the service it returns the SecurityToken which can be used for other requests. But Im not sure which tags are really neccessary for the SecurityTokenRequest because in this request there are a few uids and tag values which change each time and I dont know how they are contructed. For example the MessageId, the UserToken id, the BinarySecret Tag,...

Does someone know which tags are cructial and which are not?

I used a HttpsUrlConnection and an OutputStream:

        URL url = new URL(SSL_URL);
        HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
        urlConnection.setDoOutput(true);
        urlConnection.setSSLSocketFactory(context.getSocketFactory());
        urlConnection.setHostnameVerifier(hostnameVerifier);
        urlConnection.setRequestProperty("Content-Type", "application/soap+xml; charset=utf-8");
        urlConnection.connect();
        OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());
        if (out != null)
        {
           out.write(getReqData());
           out.flush();
           out.close();
        }
        int res = urlConnection.getResponseCode();
        String message = urlConnection.getResponseMessage();
        InputStream in = urlConnection.getInputStream();
        String msg = convertStreamToString(in);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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