Can NE 1 help me with more kXML and kSOAP samples??
"Bhanu" <[email protected]> Tue, 3 Jun 2003 18:35:11 +0530
| Newsgroups | gmane.comp.java.enhydra.kxml |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
------=_NextPart_000_0017_01C329FE.DD8DDE00
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
=20
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.=20
=20
Now, my question here is:
=20
1. How do I parse and get the data from the response I got from the =
server since it contains lot of things?
=20
2. I have this XML
=20
<Cust_Appointment><Record><Internal_Cust_Id>1</Internal_Cust_Id><Appointm=
ent_Type>1</Appointment_Type><Appointment_Date>5-June-2003</Appointment_D=
ate><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>
=20
How do I send it to the Server?? I was able to connect to the server but =
it returned a Fault as below:
=20
Buffer:<?xml version=3D"1.0" encoding=3D"utf-8"?>
<soap:Envelope xmlns:soap=3D"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:
=20
package soaptest;
=20
import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
=20
import org.ksoap.*;
import org.kxml.*;
import org.kxml.io.*;
import org.kxml.parser.*;
=20
public class clsHTTP extends Form implements CommandListener {
=20
// static final String serviceNamespace =3D =
"http://pocketdba.com/webservices/";
static final String serviceNamespace =3D "http://tempuri.org/";
static final String =
xmlData=3D"<Cust_Appointment><Record><Internal_Cust_Id>1</Internal_Cust_I=
d><Appointment_Type>1</Appointment_Type><Appointment_Date>5-June-2003</Ap=
pointment_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 =3D new TextField ("UserName :", "ss", 4, =
TextField.ANY);
StringItem resultItem =3D new StringItem ("", "");
Command getCommand =3D new Command ("Get", Command.SCREEN, 1);
Command sendCommand =3D new Command ("Send", Command.SCREEN, 2);
=20
public clsHTTP() {
super("Get Data");
=20
append (fromField);
append (resultItem);
addCommand (getCommand);
addCommand (sendCommand);
=20
setCommandListener (this);
}
=20
public void commandAction (Command c, Displayable d) {
if(c.getLabel()=3D=3D"Get"){
try {
String from =3D fromField.getString ();
ByteArrayOutputStream bos =3D new ByteArrayOutputStream ();
SoapObject request =3D new SoapObject (serviceNamespace, =
"DownloadAppointmentConfig");
request.addProperty ("uName", fromField.getString ());
=20
ClassMap classMap =3D new ClassMap();
classMap.prefixMap =3D new PrefixMap(classMap.prefixMap, "tns", =
"http://tempuri.org/");
SoapEnvelope envelope =3D new SoapEnvelope (classMap);
envelope.setBody (request);
=20
XmlWriter xw =3D new XmlWriter (new OutputStreamWriter (bos));
envelope.write (xw);
xw.flush ();
=20
byte [] data =3D bos.toByteArray();
// System.out.println (new String (data));
=20
HttpConnection connection =3D (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/Download=
AppointmentConfig\"");
OutputStream os =3D connection.openOutputStream ();
os.write (data);
os.flush ();
=20
InputStream is=3D((StreamConnection) connection).openInputStream =
();
int buffSize=3D200;
byte[] buff =3D new byte[buffSize];
ByteArrayOutputStream bytebuff=3Dnew =
ByteArrayOutputStream(buffSize);
int eof=3D0;
while(eof!=3D-1) {
eof=3Dis.read(buff);
if (eof!=3D-1) {
bytebuff.write(buff,0,eof);
}
}
is.close();
=20
String response =3D new String(bytebuff.toByteArray());
System.out.println (response);
=20
/* Reader reader =3D new InputStreamReader(new
ByteArrayInputStream(bytebuff.toByteArray()));
XmlParser parser =3D new XmlParser (reader);
SoapEnvelope resultEnvelope =3D new SoapEnvelope ();
resultEnvelope.parse (parser);
resultItem.setLabel ("amount :");
String result =3D (String)resultEnvelope.getResult();
result =3D result.substring(0,result.indexOf(".")+3);
resultItem.setText (" "+result);
reader.close ();
*/
connection.close ();
os.close ();
=20
}
catch (Exception e) {
resultItem.setLabel ("Error:");
resultItem.setText (e.toString ());
}
}
else{
=20
/* Sending data to SERVER*/
=20
try {
String from =3D fromField.getString ();
ByteArrayOutputStream bos =3D new ByteArrayOutputStream ();
SoapObject request =3D new SoapObject (serviceNamespace, =
"Upload_Cust_Appointment");
request.addProperty ("uName", fromField.getString ());
request.addProperty ("fileName", "Cust_Appointment");
=20
ClassMap classMap =3D new ClassMap();
classMap.prefixMap =3D new PrefixMap(classMap.prefixMap, "tns", =
"http://tempuri.org/");
SoapEnvelope envelope =3D new SoapEnvelope (classMap);
envelope.setBody (request);
=20
XmlWriter xw =3D new XmlWriter (new OutputStreamWriter (bos));
envelope.write (xw);
xw.flush ();
=20
byte [] data =3D bos.toByteArray();
=20
HttpConnection connection =3D (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_C=
ust_Appointment\"");
OutputStream os =3D connection.openOutputStream ();
os.write (data);
// os.write (xmlData.getBytes());
os.flush ();
os.close ();
=20
InputStream is=3D((StreamConnection) connection).openInputStream =
();
int buffSize=3D200;
byte[] buff =3D new byte[buffSize];
ByteArrayOutputStream bytebuff =3D new =
ByteArrayOutputStream(buffSize);
int eof=3D0;
while(eof!=3D-1) {
eof=3Dis.read(buff);
if (eof!=3D-1) {
bytebuff.write(buff,0,eof);
}
}
is.close();
=20
String response =3D new String(bytebuff.toByteArray());
System.out.println (response);
=20
connection =3D (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_C=
ust_Appointment\"");
os =3D connection.openOutputStream ();
=20
os.write (xmlData.getBytes());
os.flush ();
=20
int datum;
long byteCount;
StringBuffer buffer =3D new StringBuffer();
is=3D((StreamConnection) connection).openInputStream ();
=20
for(byteCount =3D 0; (datum=3Dis.read()) > 0; byteCount++) {
buffer.append((char)datum);
}
=20
os.close ();
=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");
System.out.println("Buffer:" + buffer.toString());
=
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");
}
catch (Exception e) {
resultItem.setLabel ("Error:");
resultItem.setText (e.toString ());
}
}
}
=20
private static byte[] extractXml(byte[] extractFrom){
byte[] result;
int off=3D0;
boolean nonStop=3Dtrue;
for(int i=3D0;nonStop;i++){
if (extractFrom[i]=3D=3D60) {
off=3Di;
nonStop=3Dfalse;
}
}
=20
result=3Dnew byte[extractFrom.length -off];
for(int i=3Doff;i<extractFrom.length;i++){
result[i-off]=3DextractFrom[i];
}
return result;
}
}
=20
Any help would be appreciated.
=20
Thanks in advance
=20
Bhanu
------=_NextPart_000_0017_01C329FE.DD8DDE00
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<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'"><?xml:namespace prefix =3D o =
ns =3D=20
"urn:schemas-microsoft-com:office:office" /><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 code=20
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 right=20
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 =
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; if=20
(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=20
(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=20
("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; if=20
(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 =
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></BODY></HTML>
------=_NextPart_000_0017_01C329FE.DD8DDE00--