我用ComMax模拟客户端发起请求,业务处理流程正常,但是没有返回报文:
TX:111111201109141406231111111111111111111115000287452 5000 (09:44:12:077)
和其他模块联调时业务处理流程正常,可是那边客户端接收不到我回写的SOCKET报文,报连接超时错误,请高手帮忙看看:
public class SocketServer {
public SocketServer(){
Socket incoming;
ServerSocket so;
try{
so= new ServerSocket(9731);
System.out.println("等待客户端连接");
while(true){
try{
incoming = so.accept( );
System.out.println("已连接客户端");
GetInfo gi=new GetInfo(incoming);
} catch (IOException e){
so.close();
e.printStackTrace();
}
}
}catch (IOException e){
e.printStackTrace();
}
}
public static void main(String[] args){
PropertyConfigurator.configure("E:\\Myeclipse\\workspace\\oufeitest\\src\\oufei\\test\\log4j.properties");
new SocketServer();
}
private static class GetInfo implements Runnable{ //?????
private Socket incoming;
private String s=null;
private BufferedReader b;
private BufferedWriter c;
Thread t;
public GetInfo(Socket incoming){
try{
this.incoming=incoming;
b=new BufferedReader(new InputStreamReader(incoming.getInputStream()));
// c=new BufferedWriter(new OutputStreamWriter(incoming.getOutputStream()));
t=new Thread(this);
t.start();
}catch(IOException e){
e.printStackTrace();
}
}
public void run(){
try{
Logger logger=Logger.getLogger(SocketServer.class);
String lines;
String line="";
while ((lines = b.readLine()) != null){
line+=lines;
}
System.out.println("line----"+line);
System.out.println(line.length());
if(line.length()%63!=0){
logger.info("交换平台发送的报文长度不正确!");
c.write("");
} else {
List<String> list1 = new ArrayList<String>();
for(int i=0;i<line.length();i+=63){
list1.add(line.substring(i,i+63));
}
Iterator list=list1.iterator();
while(list.hasNext()){
String co="";
co=(String) list.next();
logger.info("后台socket发送给我的内容:"+co);
String post_url="http://esales1.ofcard.com:8088/onlineorder.do";
String content=ConcatPackage.getPackage(co);
//用post方式发送http请求
String xmlcontent="";
try {
xmlcontent=Sender.readContentFromPost(post_url, content);
} catch (IOException e) {
// TODO Auto-generated catch block