### Clone ksoap2-android Repository Source: http://simpligility.github.io/ksoap2-android/developing.html Use this command to get the source code from GitHub. ```bash git clone git@github.com:simpligility/ksoap2-android.git ``` -------------------------------- ### Send Byte Array with MarshalBase64 Source: http://simpligility.github.io/ksoap2-android/tips.html This snippet shows how to send a byte array, such as an image or PDF, by enabling MarshalBase64 and encoding the array. It includes file handling and network transport setup. ```Java String path = Environment.getExternalStorageDirectory().getAbsolutePath(); String FILE = "/PdfCheck1.pdf"; String pathCompleto = path+FILE; Log.i("","Path completo : "+ pathCompleto); byte[] filefirma = convertDocToByteArray(pathCompleto); Intervento.addProperty("FileFirma",filefirma); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); new MarshalDouble().register(envelope); new MarshalBase64().register(envelope); //serialization envelope.encodingStyle = SoapEnvelope.ENC; envelope.bodyOut = request; envelope.dotNet = true; envelope.setOutputSoapObject(request); envelope.setAddAdornments(false); envelope.implicitTypes= true; // Log.i("Envelope","settata"); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.debug = true; Log.i("","Prima di androidHttpTransport.call "); androidHttpTransport.call(SOAP_ACTION, envelope); Log.i("","" + androidHttpTransport.requestDump); Log.i("","" + androidHttpTransport.responseDump); Log.i("call","call"); SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse(); Log.i("SoapPrimitive","Result" + resultsRequestSOAP); Log.i("GetAttribute","Count" + resultsRequestSOAP.getAttributeCount()); b = Boolean.parseBoolean(resultsRequestSOAP.toString()); Log.i("","risultato boolean Straordinario "+b); public static byte[] convertDocToByteArray(String sourcePath) throws IOException { File f = new File(sourcePath); long l = f.length(); byte [] buf = new byte[(int) l]; ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { InputStream fis = new FileInputStream(sourcePath); for (int readNum; (readNum = fis.read(buf)) != -1;) { bos.write(buf, 0, readNum); Log.i("","read num bytes: "+readNum); } } catch (IOException e) { System.out.println("IO Ex"+e); } byte[] bytes = bos.toByteArray(); // for(int i = 0;i implements KvmSerializable { private static final long serialVersionUID = -1166006770093411055L; @Override public Object getProperty(int arg0) { return this.get(arg0); } @Override public int getPropertyCount() { return 1; } @Override public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) { arg2.name = "string"; arg2.type = PropertyInfo.STRING_CLASS; } @Override public void setProperty(int arg0, Object arg1) { this.add(arg1.toString()); } } ``` -------------------------------- ### Access Received Data from Custom Serializable Vector Source: http://simpligility.github.io/ksoap2-android/tips.html When receiving a response, cast the bodyIn of the soapEnvelope to your custom serializable Vector class. Access elements using standard Vector methods like get(). ```java DocumentIDs documentIdResultVector = (DocumentIDs)soapEnvelope.bodyIn; String resultString = documentIdResultVector.get(0); ``` -------------------------------- ### Build Documentation Website with Maven Source: http://simpligility.github.io/ksoap2-android/developing.html Generate the project's documentation website using Maven. ```bash mvn clean site -N ``` -------------------------------- ### Build and Site Generation Source: http://simpligility.github.io/ksoap2-android/releasing.html Commands to perform a full build and generate the project site. Ensure the upcoming release version is updated in `org.ksoap2.transport.Transport.USER_AGENT` before running. ```bash mvn clean install mvn site -N ``` -------------------------------- ### Perform Release Source: http://simpligility.github.io/ksoap2-android/releasing.html Command to initiate the release process, which includes preparing and performing the release. Ensure all tests pass, the site builds, and the changelog is up to date. ```bash mvn release:prepare release:perform ``` -------------------------------- ### Build ksoap2-android with Maven Wrapper Source: http://simpligility.github.io/ksoap2-android/developing.html Use the Maven wrapper script for building the project. ```bash mvnw clean install ``` -------------------------------- ### Build ksoap2-android with Maven Source: http://simpligility.github.io/ksoap2-android/developing.html Perform a full build of the project using Maven. ```bash mvn clean install ``` -------------------------------- ### Deploy Project Site Source: http://simpligility.github.io/ksoap2-android/releasing.html Command to deploy the project site to GitHub pages. This can be run from the release branch/tag in the `target/checkout` folder. ```bash mvn clean site-deploy -N ``` -------------------------------- ### Deploy SNAPSHOT Version Source: http://simpligility.github.io/ksoap2-android/releasing.html Command to deploy a SNAPSHOT version of the library to the Sonatype snapshots repository for testing. ```bash mvn clean deploy -P release ``` -------------------------------- ### GitHub Credentials Configuration for Site Deployment Source: http://simpligility.github.io/ksoap2-android/releasing.html XML configuration for `settings.xml` to store GitHub credentials for site deployment to GitHub pages. ```xml github yourname yourpassword ``` -------------------------------- ### Manual Deploy After Release Failure Source: http://simpligility.github.io/ksoap2-android/releasing.html Command to manually deploy artifacts if the `release:perform` phase fails. This can be run from the `target/checkout` folder or a checked-out branch of the tag. ```bash mvn deploy -P release ``` -------------------------------- ### Prepare Request with Custom Serializable Vector Source: http://simpligility.github.io/ksoap2-android/tips.html Instantiate and populate a custom serializable Vector, then create a PropertyInfo object to add it to the SoapObject request. Ensure to add a mapping for the custom class to the SoapSerializationEnvelope. ```java DocumentIDs documentIdVector = new DocumentIDs(); documentIdVector.add("any String"); PropertyInfo documentIdsPropertyInfo = new PropertyInfo(); documentIdsPropertyInfo.setName("documentIds"); documentIdsPropertyInfo.setValue(documentIdVector); documentIdsPropertyInfo.setType(documentIdVector.getClass()); Request = new SoapObject(NAMESPACE, METHOD_NAME); Request.addProperty(documentIdsPropertyInfo); Request.addProperty("pluginType", "another string"); Request.addProperty("xmlConfiguration", "next string"); soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); soapEnvelope.setOutputSoapObject(Request); soapEnvelope.addMapping(NAMESPACE, "documentIds", new DocumentIDs().getClass()); ``` -------------------------------- ### Configure HttpsTransportSE with Custom SSLSocketFactory Source: http://simpligility.github.io/ksoap2-android/tips.html Shows how to configure an HttpsTransportSE to use a custom SSLSocketFactory, enabling support for self-signed certificates by loading them from a KeyStore. This is crucial for connecting to secure endpoints with non-standard certificates. ```java public class ConnectionWithSelfSignedCertificate { private KeyStore keyStore; public ConnectionWithSelfSignedCertificate(KeyStore keyStore) { this.keyStore = keyStore; } public void dummy(String host, int port, String file, int timeout) throws Exception { SoapObject client = new SoapObject("", "dummy"); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.bodyOut = client; HttpsTransportSE transport = new HttpsTransportSE(host, port, file, timeout); ((HttpsServiceConnectionSE) transport.getConnection()).setSSLSocketFactory(getSSLSocketFactory()); transport.call("", envelope); } private SSLSocketFactory getSSLSocketFactory() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException { TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(keyStore); SSLContext context = SSLContext.getInstance("SSL"); context.init(null, tmf.getTrustManagers(), null); return context.getSocketFactory(); } } ``` -------------------------------- ### Configure Maven Repository for ksoap2-android Releases Source: http://simpligility.github.io/ksoap2-android/getting-started.html If not using a repository manager, add this repository configuration to your Maven settings.xml or pom.xml to fetch releases from Sonatype. ```xml ossrh https://oss.sonatype.org/content/repositories/ksoap2-android-releases/ ``` -------------------------------- ### OSSRH Credentials Configuration Source: http://simpligility.github.io/ksoap2-android/releasing.html XML configuration for `settings.xml` to store OSSRH credentials for deployment. ```xml ossrh yourname yourpassword ``` -------------------------------- ### Add Array of Complex Objects to Request Source: http://simpligility.github.io/ksoap2-android/tips.html Demonstrates how to construct an XML structure representing an array of complex objects, such as a list of users, for a SOAP request. This involves creating nested SoapObjects and adding them as properties. ```java SoapObject users = new SoapObject(NAMESPACE, "users"); SoapObject john = new SoapObject(NAMESPACE, "user"); john.addProperty("name", "john"); john.addProperty("age", 12); SoapObject marie = new SoapObject(NAMESPACE, "user"); john.addProperty("name", "marie"); john.addProperty("age", 27); users.addSoapObject(john); users.addSoapObject(marie); ``` -------------------------------- ### Add ksoap2-android Dependency to Maven Project Source: http://simpligility.github.io/ksoap2-android/getting-started.html Include this dependency in your Maven project's POM file to use the ksoap2-android library. Ensure your repository manager is configured to access Sonatype repositories. ```xml ... com.google.code.ksoap2-android ksoap2-android 3.6.4 ... ``` -------------------------------- ### Enable HTTP Transport Debugging Source: http://simpligility.github.io/ksoap2-android/tips.html Turn on debugging for the HttpTransport object to inspect raw XML requests and responses. Set a breakpoint after the call to httpTransport.call() to examine the requestDump and responseDump properties. ```java httpTransport.debug = true; // Set breakpoint here: httpTransport.call(soapaction, envelope); // Inspect httpTransport.requestDump and httpTransport.responseDump ``` -------------------------------- ### Add ksoap2-extra-ntlm Dependency to Maven Project Source: http://simpligility.github.io/ksoap2-android/getting-started.html Declare this dependency in your Maven project if you need the ksoap2-extra-ntlm functionality. Check the project source for other available libraries. ```xml com.google.code.ksoap2-android ksoap2-extra-ntlm 3.6.4 ``` -------------------------------- ### Use HashMap for Array of Parameters Source: http://simpligility.github.io/ksoap2-android/tips.html This snippet demonstrates how to use a HashMap with MarshalHashTable to send an array of parameters in a ksoap2-android request. It's useful for services expecting structured parameter collections. ```Java Hashtable hashtable = new Hashtable(); hashtable.put("is_report", false); hashtable.put("r_how", 1); _client.addProperty("params",hashtable); SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); _envelope.bodyOut = _client; HttpTransportSE _ht = new HttpTransportSE("http://www.drebedengi.ru/soap/"); _ht.debug = true; (new MarshalHashtable()).register(_envelope); ``` -------------------------------- ### Marshal Three-Dimensional String Array Source: http://simpligility.github.io/ksoap2-android/tips.html Implements the Marshal interface to handle the serialization and deserialization of a three-dimensional string array. This is useful for sending complex array structures to a SOAP service. ```java import org.ksoap2.serialization.Marshal; import org.ksoap2.serialization.PropertyInfo; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlSerializer; import java.io.IOException; public class MarshallArray implements Marshal { //this method doesn't work yet public Object readInstance(XmlPullParser parser, String namespace, String name, PropertyInfo expected) throws IOException, XmlPullParserException { return parser.nextText(); } public void register(SoapSerializationEnvelope cm) { cm.addMapping(cm.xsd, "String[][][]", String[][][].class, this); } public void writeInstance(XmlSerializer writer, Object obj) throws IOException { String[][][] myArray = (String[][][]) obj; for (int i = 0; i < myArray.length; i++) { writer.startTag("", "ArrayOfArrayOfString"); for (int j = 0; j < myArray[i].length; j++) { writer.startTag("", "ArrayOfString"); for (int k = 0; k < myArray[i][j].length; k++) { writer.startTag("", "string"); writer.text(myArray[i][j][k]); writer.endTag("", "string"); } writer.endTag("", "ArrayOfString"); } writer.endTag("", "ArrayOfArrayOfString"); } } } ``` -------------------------------- ### Parse SoapObject Array to POJO Array Source: http://simpligility.github.io/ksoap2-android/tips.html Manually parses an array of SoapObjects into a list of custom POJO objects. This is useful when the response from a web service is a complex structure that needs to be mapped to application-specific objects. ```java ArrayList pojos = null; int totalCount = soapobject.getPropertyCount(); if (detailsTotal > 0 ) { pojos = new ArrayList(); for (int detailCount = 0; detailCount < totalCount; detailCount++) { SoapObject pojoSoap = (SoapObject) soapobject.getProperty(detailCount); Pojo Pojo = new Pojo(); Pojo.idNumber = pojoSoap.getProperty("idNumber").toString(); Pojo.quantity = pojoSoap.getProperty("quantity").toString(); pojos.add(Pojo); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.