我的xml请求如下:
<?xml version="1.0" encoding="GB2312"?>
<Spaccess_Req Ver="1.0.0">
       <HDR Version="1.0.0">
              <Client>
                     <Id>4000008</Id>
                     <Pwd>LBS_8263</Pwd>
              </Client>
       </HDR>
       <!--320*250,Basemap+Include-->   
       <MPR>
              <Output width="1024" height="768" format="image/jpg">
                     <BBoxContext>
                            <pos dimension="2">119.491 26.14623</pos>
                            <pos dimension="2">119.591 26.24623</pos>
                     </BBoxContext>
              </Output>
              <Basemap filter="Include">
                     <Layer name="AreaCoverage"></Layer>
                     <Layer name="Road"></Layer>
                     <Layer name="Highway"></Layer>
                     <Layer name="River"></Layer>
                     <Layer name="Greenbelt"></Layer>
                  
              </Basemap>
       </MPR>
</Spaccess_Req>我在applet中,用一个字符串代替它:
String yinhao="\"";
request="<?xml version="+yinhao+"1.0"+yinhao+" encoding="+yinhao+"GB2312"+yinhao+"?><Spaccess_Req Ver="+yinhao+"1.0.0"+yinhao+"><HDR Version="+yinhao+"1.0.0"+yinhao+"><Client><Id>4000008</Id><Pwd>LBS_8263</Pwd></Client></HDR><!--320*250,Basemap+Include--><MPR><Output width="+yinhao+"1024"+yinhao+" height="+yinhao+"768"+yinhao+" format="+yinhao+"image/jpg"+yinhao+"><BBoxContext><pos dimension="+yinhao+"2"+yinhao+">119.491 26.14623</pos><pos dimension="+yinhao+"2"+yinhao+">119.591 26.24623</pos></BBoxContext></Output><Basemap filter="+yinhao+"Include"+yinhao+"><Layer name="+yinhao+"AreaCoverage"+yinhao+"></Layer><Layer name="+yinhao+"Road"+yinhao+"></Layer><Layer name="+yinhao+"Highway"+yinhao+"></Layer><Layer name="+yinhao+"River"+yinhao+"></Layer><Layer name="+yinhao+"Greenbelt"+yinhao+"></Layer></Basemap></MPR></Spaccess_Req>";然后,用下面的代码进行发送改请求:
try
{
URL url=new URL("http://220.200.38.21:8080/acc/localacc");
URLConnection conn=url.openConnection();
//使浏览器不缓存这个URL
conn.setUseCaches(false);
//允许接收服务器发来的数据
conn.setDoInput(true);
//允许发送数据到服务器
conn.setDoOutput(true);
            
String postData=URLEncoder.encode(request); ByteArrayOutputStream byteOut=new ByteArrayOutputStream(512);
//把数据写入到字节缓冲区中
PrintWriter  out=new PrintWriter(byteOut);
out.println(postData);
out.flush(); String lengthString=String.valueOf(byteOut.size());
//用post请求需要设置Content-Length
conn.setRequestProperty("Content-Length",lengthString);
conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); //用post数据连接到输出流中
byteOut.writeTo(conn.getOutputStream());            
/*byte buf[]=byteOut.toByteArray();
//因为序列化的对象是用二进制数据发送的
conn.setRequestProperty("Content-type","application/octet-stream");
conn.setRequestProperty("Content-length",""+buf.length);
DataOutputStream dataOut=new DataOutputStream(conn.getOutputStream());
dataOut.write(buf);
dataOut.flush();
dataOut.close();*/
             
    BufferedReader in=new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
String linefeed="\r\n";
while((line=in.readLine())!=null)
{
                result.append(line);
result.append(linefeed);
}
}
但运行时,却出现accessDenied(java.net.SocketPermission)的错误,是什么原因呢???怎么办呢??先谢了!!