RE: Can NE 1 help me with more kXML and kSOAP samples??
"Anne Racel" <[email protected]> Tue, 10 Jun 2003 08:41:21 -0400
| Newsgroups | gmane.comp.java.enhydra.kxml |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format. ------=_NextPart_000_0000_01C32F2C.118B8A90 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Maybe I'm missing something. But all I see in your request is the user name. I don't see where you actually add your 'xmlData' to the request. And the error indicates it's looking for a <Custo_Appointment> tag. -----Original Message----- From: [email protected] [mailto:[email protected]]On Behalf Of Bhanu Sent: Tuesday, June 03, 2003 9:05 AM To: [email protected] Subject: Kxml: Can NE 1 help me with more kXML and kSOAP samples?? Hi, I am new to J2ME, just started working on a project where my J2ME application needs to receive/send data to .NET web service. I have written a sample code to test the service. I was able to get the data from the server. Now, my question here is: 1. How do I parse and get the data from the response I got from the server since it contains lot of things? 2. I have this XML <Cust_Appointment><Record><Internal_Cust_Id>1</Internal_Cust_Id><Appointment _Type>1</Appointment_Type><Appointment_Date>5-June-2003</Appointment_Date><U ser_Id>1</User_Id><Description><![CDATA[Mobile Demo]]></Description><Active_Date>5-June-2002</Active_Date><Inactive_Date> 5-June-2004</Inactive_Date></Record></Cust_Appointment> How do I send it to the Server?? I was able to connect to the server but it returned a Fault as below: Buffer:<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <soap:Fault> <faultcode>soap:Client</faultcode> <faultstring>Server was unable to read request. --> The &lt;Cust_Appointment&gt; tag from namespace is expected. Line 1, position 2.</faultstring> <detail /> </soap:Fault> </soap:Body> </soap:Envelope> Here is the sample I am using right now for reading/sending data from/to the server: package soaptest; import java.io.*; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.io.*; import org.ksoap.*; import org.kxml.*; import org.kxml.io.*; import org.kxml.parser.*; public class clsHTTP extends Form implements CommandListener { // static final String serviceNamespace = "http://pocketdba.com/webservices/"; static final String serviceNamespace = "http://tempuri.org/"; static final String xmlData="<Cust_Appointment><Record><Internal_Cust_Id>1</Internal_Cust_Id><Ap pointment_Type>1</Appointment_Type><Appointment_Date>5-June-2003</Appointmen t_Date><User_Id>1</User_Id><Description><![CDATA[Mobile Demo]]></Description><Active_Date>5-June-2002</Active_Date><Inactive_Date>5- June-2004</Inactive_Date></Record></Cust_Appointment>"; TextField fromField = new TextField ("UserName :", "ss", 4, TextField.ANY); StringItem resultItem = new StringItem ("", ""); Command getCommand = new Command ("Get", Command.SCREEN, 1); Command sendCommand = new Command ("Send", Command.SCREEN, 2); public clsHTTP() { super("Get Data"); append (fromField); append (resultItem); addCommand (getCommand); addCommand (sendCommand); setCommandListener (this); } public void commandAction (Command c, Displayable d) { if(c.getLabel()=="Get"){ try { String from = fromField.getString (); ByteArrayOutputStream bos = new ByteArrayOutputStream (); SoapObject request = new SoapObject (serviceNamespace, "DownloadAppointmentConfig"); request.addProperty ("uName", fromField.getString ()); ClassMap classMap = new ClassMap(); classMap.prefixMap = new PrefixMap(classMap.prefixMap, "tns", "http://tempuri.org/"); SoapEnvelope envelope = new SoapEnvelope (classMap); envelope.setBody (request); XmlWriter xw = new XmlWriter (new OutputStreamWriter (bos)); envelope.write (xw); xw.flush (); byte [] data = bos.toByteArray(); // System.out.println (new String (data)); HttpConnection connection = (HttpConnection) Connector.open ("http://MMSServer/SyncSvr/SyncSvrObj.asmx",Connector.READ_WRITE); connection.setRequestMethod (HttpConnection.POST); connection.setRequestProperty ("Content-Type", "text/xml"); connection.setRequestProperty ("Connection", "close"); connection.setRequestProperty ("Content-Length", ""+data.length); connection.setRequestProperty("SOAPAction","\"http://tempuri.org/DownloadApp ointmentConfig\""); OutputStream os = connection.openOutputStream (); os.write (data); os.flush (); InputStream is=((StreamConnection) connection).openInputStream (); int buffSize=200; byte[] buff = new byte[buffSize]; ByteArrayOutputStream bytebuff=new ByteArrayOutputStream(buffSize); int eof=0; while(eof!=-1) { eof=is.read(buff); if (eof!=-1) { bytebuff.write(buff,0,eof); } } is.close(); String response = new String(bytebuff.toByteArray()); System.out.println (response); /* Reader reader = new InputStreamReader(new ByteArrayInputStream(bytebuff.toByteArray())); XmlParser parser = new XmlParser (reader); SoapEnvelope resultEnvelope = new SoapEnvelope (); resultEnvelope.parse (parser); resultItem.setLabel ("amount :"); String result = (String)resultEnvelope.getResult(); result = result.substring(0,result.indexOf(".")+3); resultItem.setText (" "+result); reader.close (); */ connection.close (); os.close (); } catch (Exception e) { resultItem.setLabel ("Error:"); resultItem.setText (e.toString ()); } } else{ /* Sending data to SERVER*/ try { String from = fromField.getString (); ByteArrayOutputStream bos = new ByteArrayOutputStream (); SoapObject request = new SoapObject (serviceNamespace, "Upload_Cust_Appointment"); request.addProperty ("uName", fromField.getString ()); request.addProperty ("fileName", "Cust_Appointment"); ClassMap classMap = new ClassMap(); classMap.prefixMap = new PrefixMap(classMap.prefixMap, "tns", "http://tempuri.org/"); SoapEnvelope envelope = new SoapEnvelope (classMap); envelope.setBody (request); XmlWriter xw = new XmlWriter (new OutputStreamWriter (bos)); envelope.write (xw); xw.flush (); byte [] data = bos.toByteArray(); HttpConnection connection = (HttpConnection) Connector.open ("http://MMSServer/SyncSvr/SyncSvrObj.asmx",Connector.READ_WRITE); connection.setRequestMethod (HttpConnection.POST); connection.setRequestProperty ("Content-Type", "text/xml"); connection.setRequestProperty ("Connection", "close"); connection.setRequestProperty ("Content-Length", "" + data.length); connection.setRequestProperty("SOAPAction","\"http://tempuri.org/Upload_Cust _Appointment\""); OutputStream os = connection.openOutputStream (); os.write (data); // os.write (xmlData.getBytes()); os.flush (); os.close (); InputStream is=((StreamConnection) connection).openInputStream (); int buffSize=200; byte[] buff = new byte[buffSize]; ByteArrayOutputStream bytebuff = new ByteArrayOutputStream(buffSize); int eof=0; while(eof!=-1) { eof=is.read(buff); if (eof!=-1) { bytebuff.write(buff,0,eof); } } is.close(); String response = new String(bytebuff.toByteArray()); System.out.println (response); connection = (HttpConnection) Connector.open ("http://MMSServer/SyncSvr/SyncSvrObj.asmx",Connector.READ_WRITE); connection.setRequestMethod (HttpConnection.POST); connection.setRequestProperty ("Content-Type", "text/xml"); connection.setRequestProperty ("Connection", "close"); connection.setRequestProperty ("Content-Length", "" + xmlData.length()); connection.setRequestProperty("SOAPAction","\"http://tempuri.org/Upload_Cust _Appointment\""); os = connection.openOutputStream (); os.write (xmlData.getBytes()); os.flush (); int datum; long byteCount; StringBuffer buffer = new StringBuffer(); is=((StreamConnection) connection).openInputStream (); for(byteCount = 0; (datum=is.read()) > 0; byteCount++) { buffer.append((char)datum); } os.close (); System.out.println("==============buff====================="); System.out.println("Buffer:" + buffer.toString()); System.out.println("==================================="); } catch (Exception e) { resultItem.setLabel ("Error:"); resultItem.setText (e.toString ()); } } } private static byte[] extractXml(byte[] extractFrom){ byte[] result; int off=0; boolean nonStop=true; for(int i=0;nonStop;i++){ if (extractFrom[i]==60) { off=i; nonStop=false; } } result=new byte[extractFrom.length -off]; for(int i=off;i<extractFrom.length;i++){ result[i-off]=extractFrom[i]; } return result; } } Any help would be appreciated. Thanks in advance Bhanu ------=_NextPart_000_0000_01C32F2C.118B8A90 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML xmlns:o =3D "urn:schemas-microsoft-com:office:office"><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial color=3D#0000ff size=3D2> <DIV><SPAN class=3D500493417-04062003><FONT face=3DArial color=3D#0000ff = size=3D2>Maybe=20 I'm missing something. But all I see in your request is the user=20 name. I don't see where you actually add your 'xmlData' to the=20 request. And the error indicates it's looking for a=20 <Custo_Appointment> tag.</FONT></SPAN></DIV></FONT></DIV> <BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px"> <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT = face=3DTahoma=20 size=3D2>-----Original Message-----<BR><B>From:</B> = [email protected]=20 [mailto:[email protected]]<B>On Behalf Of = </B>Bhanu<BR><B>Sent:</B>=20 Tuesday, June 03, 2003 9:05 AM<BR><B>To:</B>=20 [email protected]<BR><B>Subject:</B> Kxml: Can NE 1 help me with more = kXML and=20 kSOAP samples??<BR><BR></FONT></DIV> <DIV> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Hi,</SPAN><SPAN=20 style=3D"FONT-FAMILY: 'Arial Unicode MS'"><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">I am new to J2ME, just = started=20 working on a project where my J2ME application needs=20 to receive/send data to .NET web service. I have written a = sample=20 code to test the service. I was able to get the data from the server.=20 </SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Now, my question here=20 is:</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><STRONG><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">1. How do I parse and = get the data=20 from the response I got from the server since it contains lot of=20 things?</SPAN></STRONG><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><STRONG><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </SPAN></STRONG>=20 <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><STRONG><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">2. I have this=20 XML</SPAN></STRONG><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"><Cust_Appointment><Record><Internal_Cust_Id>1<= ;/Internal_Cust_Id><Appointment_Type>1</Appointment_Type>&= lt;Appointment_Date>5-June-2003</Appointment_Date><User_Id>= ;1</User_Id><Description><![CDATA[Mobile=20 = Demo]]></Description><Active_Date>5-June-2002</Active_D= ate><Inactive_Date><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial">5-June-2004</Inactive_Date></Record></Cust_Appointm= ent><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><STRONG><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">How do I send it to the = Server?? I=20 was able to connect to the server but it returned a Fault as=20 below:</SPAN></STRONG><SPAN=20 style=3D"FONT-FAMILY: 'Arial Unicode MS'; mso-fareast-font-family: = 'Times New Roman'"><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Buffer:<?xml = version=3D"1.0"=20 encoding=3D"utf-8"?></SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"><soap:Envelope = xmlns:soap=3D"<A=20 = href=3D"http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap= .org/soap/envelope/</A>"><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"> =20 <soap:Body><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"> =20 <soap:Fault><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 <faultcode>soap:Client</faultcode><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 <faultstring>Server was unable to read request. --&gt; The=20 &amp;lt;Cust_Appointment&amp;gt; tag from namespace is = expected.=20 Line 1, position 2.</faultstring><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 <detail /><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"> =20 </soap:Fault><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"> =20 </soap:Body><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"></soap:Envelope></SPAN><SPAN=20 style=3D"FONT-FAMILY: 'Arial Unicode MS'; mso-fareast-font-family: = 'Times New Roman'"><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><STRONG><I><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Here is the sample I am = using=20 right now for reading/sending data from/to the=20 server:</SPAN></I></STRONG><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">package=20 soaptest;</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">import = java.io.*;<BR>import=20 javax.microedition.midlet.*;<BR>import = javax.microedition.lcdui.*;<BR>import=20 javax.microedition.io.*;</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">import = org.ksoap.*;<BR>import=20 org.kxml.*;<BR>import org.kxml.io.*;<BR>import=20 org.kxml.parser.*;</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">public class clsHTTP = extends Form=20 implements CommandListener {</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">// static final = String=20 serviceNamespace =3D "<A=20 = href=3D"http://pocketdba.com/webservices/">http://pocketdba.com/webservic= es/</A>";<BR> =20 static final String serviceNamespace =3D "<A=20 href=3D"http://tempuri.org/">http://tempuri.org/</A>";<BR> = static final=20 String=20 = xmlData=3D"<Cust_Appointment><Record><Internal_Cust_Id>= 1</Internal_Cust_Id><Appointment_Type>1</Appointment_Type&= gt;<Appointment_Date>5-June-2003</Appointment_Date><User_I= d>1</User_Id><Description><![CDATA[Mobile=20 = Demo]]></Description><Active_Date>5-June-2002</Active_D= ate><Inactive_Date>5-June-2004</Inactive_Date></Record&= gt;</Cust_Appointment>";<BR> =20 TextField fromField =3D new TextField ("UserName :", "ss", 4,=20 TextField.ANY);<BR> StringItem resultItem =3D new StringItem = ("",=20 "");<BR> Command getCommand =3D new Command ("Get", = Command.SCREEN,=20 1);<BR> Command sendCommand =3D new Command ("Send", = Command.SCREEN,=20 2);</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"> public clsHTTP()=20 {<BR> super("Get Data");</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"> = append=20 (fromField);<BR> append = (resultItem);<BR> =20 addCommand (getCommand);<BR> addCommand=20 (sendCommand);</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"> =20 setCommandListener (this);<BR> }</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"> public void = commandAction=20 (Command c, Displayable d) {<BR> =20 if(c.getLabel()=3D=3D"Get"){<BR> try=20 {<BR> String from =3D=20 fromField.getString ();<BR> =20 ByteArrayOutputStream bos =3D new ByteArrayOutputStream=20 ();<BR> SoapObject request = =3D new=20 SoapObject (serviceNamespace,=20 = "DownloadAppointmentConfig");<BR> &nbs= p;=20 request.addProperty ("uName", fromField.getString = ());</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 ClassMap classMap =3D new=20 ClassMap();<BR> = classMap.prefixMap =3D=20 new PrefixMap(classMap.prefixMap, "tns", "<A=20 = href=3D"http://tempuri.org/">http://tempuri.org/</A>");<BR> &n= bsp; =20 SoapEnvelope envelope =3D new SoapEnvelope=20 (classMap);<BR> = envelope.setBody=20 (request);</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 XmlWriter xw =3D new XmlWriter (new OutputStreamWriter=20 (bos));<BR> envelope.write=20 (xw);<BR> xw.flush=20 ();</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 byte [] data =3D=20 bos.toByteArray();<BR> //=20 System.out.println (new String (data));</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 HttpConnection connection =3D (HttpConnection)=20 Connector.open<BR> ("<A=20 href=3D"http://mmsserver/SyncSvr/SyncSvrObj.asmx"><FONT=20 = color=3D#0000ff>http://MMSServer/SyncSvr/SyncSvrObj.asmx",Connector.READ_= WRITE</FONT></A>);<BR> =20 connection.setRequestMethod=20 (HttpConnection.POST);<BR> =20 connection.setRequestProperty ("Content-Type",=20 "text/xml");<BR> =20 connection.setRequestProperty ("Connection",=20 "close");<BR> =20 connection.setRequestProperty ("Content-Length",=20 ""+data.length);<BR> =20 connection.setRequestProperty("SOAPAction","\"<A=20 = href=3D"http://tempuri.org/DownloadAppointmentConfig/">http://tempuri.org= /DownloadAppointmentConfig\</A>"");<BR> &nbs= p; =20 OutputStream os =3D connection.openOutputStream=20 ();<BR> os.write=20 (data);<BR> os.flush=20 ();</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 InputStream is=3D((StreamConnection) connection).openInputStream=20 ();<BR> int=20 buffSize=3D200;<BR> byte[] = buff =3D new=20 byte[buffSize];<BR> =20 ByteArrayOutputStream bytebuff=3Dnew=20 = ByteArrayOutputStream(buffSize);<BR> &= nbsp;=20 int eof=3D0;<BR> = while(eof!=3D-1)=20 {<BR> =20 = eof=3Dis.read(buff);<BR> &= nbsp;=20 if (eof!=3D-1)=20 = {<BR> =20 = bytebuff.write(buff,0,eof);<BR> = =20 }<BR> =20 }<BR> =20 is.close();</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 String response =3D new=20 = String(bytebuff.toByteArray());<BR> &n= bsp;=20 System.out.println (response);</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial">/* =20 Reader reader =3D new=20 InputStreamReader(new<BR> =20 = ByteArrayInputStream(bytebuff.toByteArray()));<BR>  = ; =20 XmlParser parser =3D new XmlParser=20 (reader);<BR> SoapEnvelope=20 resultEnvelope =3D new SoapEnvelope=20 ();<BR> resultEnvelope.parse = (parser);<BR> = resultItem.setLabel=20 ("amount :");<BR> String = result =3D=20 = (String)resultEnvelope.getResult();<BR> &nbs= p; =20 result =3D=20 = result.substring(0,result.indexOf(".")+3);<BR> &nb= sp; =20 resultItem.setText (" = "+result);<BR> =20 reader.close ();<BR> =20 */<BR> connection.close=20 ();<BR> os.close=20 ();</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 }<BR> catch (Exception e)=20 {<BR> resultItem.setLabel=20 ("Error:");<BR> = resultItem.setText=20 (e.toString ());<BR> = }<BR> =20 }<BR> else{</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> /*=20 Sending data to SERVER*/</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> try=20 {<BR> String from =3D=20 fromField.getString ();<BR> =20 ByteArrayOutputStream bos =3D new ByteArrayOutputStream=20 ();<BR> SoapObject request = =3D new=20 SoapObject (serviceNamespace,=20 = "Upload_Cust_Appointment");<BR> = =20 request.addProperty ("uName", fromField.getString=20 ());<BR> request.addProperty = ("fileName", "Cust_Appointment");</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 ClassMap classMap =3D new=20 ClassMap();<BR> = classMap.prefixMap =3D=20 new PrefixMap(classMap.prefixMap, "tns", "<A=20 = href=3D"http://tempuri.org/">http://tempuri.org/</A>");<BR> &n= bsp; =20 SoapEnvelope envelope =3D new SoapEnvelope=20 (classMap);<BR> = envelope.setBody=20 (request);</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 XmlWriter xw =3D new XmlWriter (new OutputStreamWriter=20 (bos));<BR> envelope.write=20 (xw);<BR> xw.flush=20 ();</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 byte [] data =3D bos.toByteArray();</SPAN><o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"><BR> =20 HttpConnection connection =3D (HttpConnection)=20 Connector.open<BR> ("<A=20 href=3D"http://mmsserver/SyncSvr/SyncSvrObj.asmx"><FONT=20 = color=3D#0000ff>http://MMSServer/SyncSvr/SyncSvrObj.asmx",Connector.READ_= WRITE</FONT></A>);<BR> =20 connection.setRequestMethod=20 (HttpConnection.POST);<BR> =20 connection.setRequestProperty ("Content-Type",=20 "text/xml");<BR> =20 connection.setRequestProperty ("Connection",=20 "close");<BR> =20 connection.setRequestProperty ("Content-Length", "" +=20 data.length);<BR> =20 connection.setRequestProperty("SOAPAction","\"<A=20 = href=3D"http://tempuri.org/Upload_Cust_Appointment/">http://tempuri.org/U= pload_Cust_Appointment\</A>"");<BR> &n= bsp;=20 OutputStream os =3D connection.openOutputStream=20 ();<BR> os.write=20 (data);<BR>// os.write=20 (xmlData.getBytes());<BR> = os.flush=20 ();<BR> os.close=20 ();<o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 InputStream is=3D((StreamConnection) connection).openInputStream=20 ();<BR> int=20 buffSize=3D200;<BR> byte[] = buff =3D new=20 byte[buffSize];<BR> =20 ByteArrayOutputStream bytebuff =3D new=20 = ByteArrayOutputStream(buffSize);<BR> &= nbsp;=20 int eof=3D0;<BR> = while(eof!=3D-1)=20 {<BR> =20 = eof=3Dis.read(buff);<BR> &= nbsp;=20 if (eof!=3D-1)=20 = {<BR> =20 = bytebuff.write(buff,0,eof);<BR> = =20 }<BR> =20 }<BR> =20 is.close();<o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 String response =3D new=20 = String(bytebuff.toByteArray());<BR> &n= bsp;=20 System.out.println (response);<o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 connection =3D (HttpConnection)=20 Connector.open<BR> ("<A=20 href=3D"http://mmsserver/SyncSvr/SyncSvrObj.asmx"><FONT=20 = color=3D#0000ff>http://MMSServer/SyncSvr/SyncSvrObj.asmx",Connector.READ_= WRITE</FONT></A>);<BR> =20 connection.setRequestMethod=20 (HttpConnection.POST);<BR> =20 connection.setRequestProperty ("Content-Type",=20 "text/xml");<BR> =20 connection.setRequestProperty ("Connection",=20 "close");<BR> =20 connection.setRequestProperty ("Content-Length", "" +=20 xmlData.length());<BR> =20 connection.setRequestProperty("SOAPAction","\"<A=20 = href=3D"http://tempuri.org/Upload_Cust_Appointment/">http://tempuri.org/U= pload_Cust_Appointment\</A>"");<BR> &n= bsp;=20 os =3D connection.openOutputStream ();<o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 os.write = (xmlData.getBytes());<BR> =20 os.flush ();<o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 int datum;<BR> long=20 byteCount;<BR> StringBuffer = buffer =3D=20 new StringBuffer();<BR> =20 is=3D((StreamConnection) connection).openInputStream = ();<o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 for(byteCount =3D 0; (datum=3Dis.read()) > 0; byteCount++)=20 {<BR> =20 = buffer.append((char)datum);<BR> = =20 }<o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 os.close ();<o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> =20 = System.out.println("=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3Dbuff=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D");<BR> = =20 System.out.println("Buffer:" +=20 buffer.toString());<BR> =20 = System.out.println("=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D");<BR> &nb= sp; =20 }<BR> catch (Exception e)=20 {<BR> resultItem.setLabel=20 ("Error:");<BR> = resultItem.setText=20 (e.toString ());<BR> = }<BR> =20 }<BR> }<o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"> private static = byte[]=20 extractXml(byte[] extractFrom){<BR> byte[]=20 result;<BR> int off=3D0;<BR> = boolean=20 nonStop=3Dtrue;<BR> for(int=20 i=3D0;nonStop;i++){<BR> if = (extractFrom[i]=3D=3D60)=20 {<BR> =20 off=3Di;<BR> =20 nonStop=3Dfalse;<BR> = }<BR> =20 }<o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"> = result=3Dnew=20 byte[extractFrom.length -off];<BR> for(int=20 = i=3Doff;i<extractFrom.length;i++){<BR> =20 result[i-off]=3DextractFrom[i];<BR> = }<BR> =20 return result;<BR> }<BR>}</SPAN><SPAN=20 style=3D"FONT-FAMILY: 'Arial Unicode MS'; mso-fareast-font-family: = 'Times New Roman'"><o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in = 0pt"> <o:p></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Any help would be=20 appreciated.<o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Thanks in=20 advance<o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial"> <o:p></o:p></SPAN></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20 style=3D"FONT-SIZE: 10pt; FONT-FAMILY: = Arial">Bhanu</SPAN></P></DIV></BLOCKQUOTE></BODY></HTML> ------=_NextPart_000_0000_01C32F2C.118B8A90--