Popular Posts
javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... Close window without confirm (I.E only) window.opener=null; window.open('','_self'); window.close(); focus on validating function focusOnInvalidControl() {     for (var i = 0; i < Page_Validators.length; i++) {         if (!Page_Validators[i].isvalid) {     ...
Blog Archive
Stats
ksoap sample
soap 1.1
POST /WebServiceForTest.asmx HTTP/1.1
Host: brucetsai.test
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Concat"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <AuthHeader xmlns="http://tempuri.org/">
      <Token1>string</Token1>
    </AuthHeader>
  </soap:Header>
  <soap:Body>
    <Concat xmlns="http://tempuri.org/">
      <key>string</key>
      <value>string</value>
    </Concat>
  </soap:Body>
</soap:Envelope>
soap 1.2
POST /WebServiceForTest.asmx HTTP/1.1
Host: brucetsai.test
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Header>
    <AuthHeader xmlns="http://tempuri.org/">
      <Token1>string</Token1>
    </AuthHeader>
  </soap12:Header>
  <soap12:Body>
    <Concat xmlns="http://tempuri.org/">
      <key>string</key>
      <value>string</value>
    </Concat>
  </soap12:Body>
</soap12:Envelope>
Java code :
import java.io.IOException;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.kxml2.kdom.Element;
import org.xmlpull.v1.XmlPullParserException;

public class TestKSOAP {

    public static void main(String[] args) throws IOException, XmlPullParserException {
        String namespace = "http://tempuri.org/";
        String wsdl = "http://brucetsai.test/WebServiceForTest.asmx?WSDL";
        String method = "Concat";
        String soapAction = "http://tempuri.org/Concat";

        SoapObject soap = new SoapObject(namespace, method);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        
        Element[] headers = new Element[1];
        
        Element AuthHeader = new Element();
        AuthHeader.setName("AuthHeader");
        AuthHeader.setNamespace(namespace);
        
        Element element = new Element();
        element.setName("Token1");
        element.setNamespace(namespace);        
        element.addChild(Element.TEXT, "value of token1");        
        AuthHeader.addChild(Element.ELEMENT, element);
        
        headers[0] = AuthHeader;
        
        soap.addProperty("key", "keyValue");
        soap.addProperty("value", "values");
        
        envelope.setOutputSoapObject(soap);
        envelope.headerOut = headers;
        envelope.bodyOut = soap;
        
        
        HttpTransportSE transport = new HttpTransportSE(wsdl);
        transport.call(soapAction, envelope);
        
        System.out.println(envelope.getResponse());
    }
}