First enter the code below to create the MarshalDate class.
package Marshals; import java.io.IOException; import java.util.Date; import org.kobjects.isodate.IsoDate; 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; public class MarshalDate implements Marshal { public static Class DATE_CLASS = new Date().getClass(); public Object readInstance(XmlPullParser parser, String namespace, String name, PropertyInfo expected) throws IOException, XmlPullParserException {
// In your client code:
String result3=""; try { String soapAction3 = "http://tempuri.org/HelloWorldDate"; SoapObject rpc3 = new SoapObject(serviceNamespace, "HelloWorldDate"); PropertyInfo pi = new PropertyInfo(); pi.name= "Date"; // name of the parameter in your dotnet variable pi.type = MarshalDate.DATE_CLASS; // add property with your value, I use new Date(System.currentTimeMillis() rpc3.addProperty(pi, new Date(System.currentTimeMillis())); SoapSerializationEnvelope envelope3 = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope3.bodyOut = rpc3; envelope3.dotNet = false; MarshalDate md = new MarshalDate(); md.register(envelope3); envelope3.setOutputSoapObject(rpc3); HttpTransport ht3 = new HttpTransport(serviceUrl); ht3.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); ht3.debug = true; ht3.call(soapAction3, envelope3); result3= envelope3.getResponse().toString(); } catch(Exception ex) { //if we get an exception we'll just write the msg to the screen. result3 = ex.toString(); } don't forget envelope3.dotNet = false; it is very important otherwise you will send null date value to .net.
source share