### Clone ksoap2-android Repository Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/developing.adoc Use this command to get the source code from GitHub. ```bash git clone git@github.com:simpligility/ksoap2-android.git ``` -------------------------------- ### Build Documentation Website with Maven Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/developing.adoc Generate the project's documentation website using Maven. The output will be in the target/site/ directory. ```bash mvn clean site -N ``` -------------------------------- ### Build and Site Generation Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/releasing.adoc Commands to perform a clean build and generate the project site. ```bash mvn clean install mvn site -N ``` -------------------------------- ### Deploy Project Site to GitHub Pages Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/releasing.adoc Command to deploy the project site to GitHub pages. ```bash mvn clean site-deploy -N ``` -------------------------------- ### Deploy SNAPSHOT Version Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/releasing.adoc Command to deploy a SNAPSHOT version of the library for testing. ```bash mvn clean deploy -P release ``` -------------------------------- ### Deploy from Target Checkout Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/releasing.adoc Command to deploy artifacts if the release perform phase fails, using the target/checkout folder. ```bash mvn deploy -P release ``` -------------------------------- ### Build ksoap2-android with Maven Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/developing.adoc Perform a full project build using the standard Maven command. ```bash mvn clean install ``` -------------------------------- ### Perform Release Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/releasing.adoc Command to initiate the release process, including preparing and performing the release. ```bash mvn release:prepare release:perform ``` -------------------------------- ### Build ksoap2-android with Maven Wrapper Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/developing.adoc Use the Maven wrapper script for building the project. ```bash mvnw clean install ``` -------------------------------- ### GitHub Credentials Configuration for Site Deployment Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/releasing.adoc XML configuration for GitHub server credentials in settings.xml for site deployment. ```xml github yourname yourpassword ``` -------------------------------- ### Configure Maven Repository for ksoap2-android Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/getting-started.adoc Add this repository configuration to your Maven settings.xml or pom.xml if you are not using a repository manager. ```xml ossrh https://oss.sonatype.org/content/repositories/ksoap2-android-releases/ ``` -------------------------------- ### Sending a Byte Array (e.g., Image or PDF) Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/tips.adoc Send a byte array, such as an image or a PDF file, by enabling MarshalBase64 for Base64 encoding. This involves registering the marshaller with the envelope and adding the byte array as a property. ```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(); ``` -------------------------------- ### Using HashMap for Request Parameters Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/tips.adoc Demonstrates how to use a HashMap to send an array of parameters in a ksoap2-android request. Registering MarshalHashTable is necessary for the client to correctly serialize the HashTable object. ```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); ``` -------------------------------- ### OSSRH Credentials Configuration Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/releasing.adoc XML configuration for OSSRH server credentials in settings.xml. ```xml ossrh yourname yourpassword ``` -------------------------------- ### Setting SSLSocketFactory for Self-Signed Certificates Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/tips.adoc Configure an HttpsTransportSE to use a custom SSLSocketFactory, enabling connections to servers with self-signed certificates by loading them from a KeyStore. ```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(); } } ``` -------------------------------- ### Implement Custom Array Marshaller Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/tips.adoc Implement the Marshal interface to handle custom marshalling of arrays, such as three-dimensional arrays. This involves registering the custom marshaller with the SoapSerializationEnvelope. ```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"); } } } ``` -------------------------------- ### Add ksoap2-android Dependency to Maven Project Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/getting-started.adoc Include this dependency in your Maven project's POM file to use the ksoap2-android library. ```xml ... com.google.code.ksoap2-android ksoap2-android 3.6.4 ... ``` -------------------------------- ### Enable HTTP Transport Debugging Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/tips.adoc Enable debugging on the httpTransport object to inspect raw XML requests and responses. Set a breakpoint after the call to httpTransport.call to examine the dumped data. ```java httpTransport.debug = true; // ... httpTransport.call(soapaction, envelope); // inspect httpTransport.requestDump and httpTransport.responseDump ``` -------------------------------- ### Add Extra ksoap2-android Dependency to Maven Project Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/getting-started.adoc Declare additional ksoap2-android libraries, such as ksoap2-extra-ntlm, as dependencies in your Maven project. ```xml com.google.code.ksoap2-android ksoap2-extra-ntlm 3.6.4 ``` -------------------------------- ### Build Request with Complex Type Array Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/tips.adoc Construct a SoapObject request by adding properties, including a custom complex type array. Ensure the complex type is correctly mapped using addMapping. ```java DocumentIDs documentIdVector = new DocumentIDs(); documentIdVector.add("any String"); 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()); ``` -------------------------------- ### Convert Document to Byte Array Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/tips.adoc This utility method converts a file into a byte array. It reads the file in chunks and writes them to a ByteArrayOutputStream. Ensure the file path is valid and handle potential IOExceptions. ```java 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 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); } } ``` -------------------------------- ### Adding an Array of Complex Objects to a Request Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/tips.adoc Construct an XML structure with an array of complex objects, such as a list of users, each with name and age properties. This method is suitable for ksoap2-android versions 2.5.5 and later. ```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); ``` -------------------------------- ### Receive Response with Complex Type Array Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/tips.adoc Cast the received soapEnvelope body to the custom complex type class to access array elements. Elements can then be retrieved using index-based access. ```java DocumentIDs documentIdResultVector = (DocumentIDs)soapEnvelope.bodyIn; String resultString = documentIdResultVector.get(0); ``` -------------------------------- ### Define Complex Type for Array of Strings Source: https://github.com/simpligility/ksoap2-android/blob/master/src/site/asciidoc/tips.adoc Extend Vector and implement KvmSerializable to represent an array of strings for ksoap2-android requests. This class defines how the array elements are serialized and deserialized. ```java import java.util.Hashtable; import java.util.Vector; import org.ksoap2.serialization.KvmSerializable; import org.ksoap2.serialization.PropertyInfo; public class DocumentIDs extends Vector 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()); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.