用socket post xml的问题,我的这段程序为什么取不到结果(100分)

L

leanyee

Unregistered / Unconfirmed
GUEST, unregistred user!
public static void main(String[] args) {
String s1 = "<?xml version=/"1.0/"?>" +
"<SLIR ver=/"1.1/" ext=/"1.0/">" +
"<CLIENT>" +
"<ID>lcsguodu1</ID>" +
"<PWD>lcsguodu</PWD>" +
"</CLIENT>" +
"<SERVICE_ID>servicegd-1</SERVICE_ID>" +
"<REQUESTER>8613705938687</REQUESTER>" +
"<MSIDS>" +
"<MSID msid_type=/"MSISDN/" msid_enc=/"ASC/">8613705938687</MSID>" +
"</MSIDS>" +
"<GEO_INFO coord_sys=/"LL/" datum=/"WGS-84/">" +
"<FORMAT format_type=/"LL/">ID9</FORMAT>" +
"</GEO_INFO>" +
"<PRIO prio_type=/"HIGH/"/>" +
"</SLIR>";
/* String s = "POST /LocationRequest/ HTTP/1.1" + "/n" +
"Host: 211.138.155.253:701" + "/n" +
"Content-type: text/xml" + "/n" +
"Content-length:" + s1.length() + "/n/n";
*/
String s = "POST http://211.138.155.253:701/LocationRequest "+
"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */* "+
"User-Agent: Mozilla/4.0 (compatible;
MSIE 5.5;
Windows 98) "+
"Content-Type: application/x-www-form-urlencoded "+
"Content-Length:"+s1.length()+ " "+
// "Host: 211.138.155.253 "+
"Data: "+s1;
try {
Socket socket = new Socket("211.138.155.253", 701);
socket.setSoTimeout(100000);
BufferedOutputStream out = new BufferedOutputStream(socket.
getOutputStream());
DataInputStream in = new DataInputStream(socket.getInputStream());
out.write(s.getBytes(), 0, s.length());
out.flush();
StringBuffer bs = new StringBuffer();
String responseLine;
while ( (responseLine = in.readLine()) != null) {
bs.append(responseLine + "/n");
}
String responsedata = bs.toString();
in.close();
out.close();
socket.close();
System.out.println(s);
System.out.println(responsedata);
}
catch (IOException e) {
System.out.println(e.getMessage());
}
}
 
顶部 底部