急求这段SOAP JAVA程序的解救方法,拜托高手救命阿
我用这段SOAP JAVA 从服务器传输一些信息到客户端
class Transpor 在客户端, 用来建立SOAP call 和 接受回溃的信息
class checkData在服务器, 用来从数据库中提取信息
我用UtilSnoop来截取服务器和客户端之间的xml message. 似乎 call 已经建立,因为checkData 被调用,而且能把获取的信息传输到客户端 (后面附有function执行时的xml message)。但是实际上在Transport 建立call 的时候有报错
程序运行是可以输出“before”"couldnt buld call",但是没有"after",所以出错的行是 resp = call.invoke(url, "");
系统的报错是java.NullPointerException
到底错出在哪了?
public class Transport {
public Object[][] doTran_viewList () throws Exception {
Object [][] value=null;
try{
url=new URL(log.urls);
SOAPMappingRegistry smr = new SOAPMappingRegistry();
BeanSerializer beanSer = new BeanSerializer();
Call call = new Call ();
call.setTargetObjectURI ("urn:RegistrySystem");
call.setMethodName ("ViewList");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Vector params = new Vector ();
String arg1=" ";
params.addElement (new Parameter("arg1", String.class,arg1, null));
call.setParams (params);
Response resp;
System.out.println("before");//when run this code, it will print out "before"
resp = call.invoke(url, "");
System.out.println("after");//but no after
if (!resp.generatedFault())
{
Parameter ret = resp.getReturnValue();
value = (Object[][])ret.getValue();
}
else
{
Fault fault = resp.getFault();
System.err.println("Generated fault: " + fault);
}
return value;
}catch(Exception e){
System.err.println("fail to build call");//when run, it will print out this
return value;
}
}
public class checkData{
public Object[][] ViewList (String arg1) throws IllegalArgumentException{
int p=0;
String url="jdbc:odbc:RST";
String cs="select ID,Name from course";
Connection con=null;
Statement stmt=null;
ResultSet rs =null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException:");
System.err.println(e.getMessage());
}
try {
con=DriverManager.getConnection(url);
stmt=con.createStatement();
rs=stmt.executeQuery(cs);
while(rs.next()){p++;}
} catch(SQLException ex) {
System.err.println("SQLException: "+ex.getMessage());
}
Object[][] value = new Object[p][2];
try {
con=DriverManager.getConnection(url);
stmt=con.createStatement();
rs=stmt.executeQuery(cs);
for(p=0;rs.next();p++) {
String i = rs.getString("ID");
String n = rs.getString("Name");
value[p][0] =i;
value[p][1] =n;
}
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: "+ex.getMessage());
}
finally{
if (rs!=null) {
try {
rs.close();
} catch (Exception ex) {
}
} //end of if(rs)
if (stmt!=null) {
try {
stmt.close();
} catch (Exception ex) {
}
}//end of if(stm)
if (con!=null) {
try {
con.close();
} catch (Exception ex) {
}
}//end of if(con)
}
return value;
}
the UtilSnoop fetch message from server to client:
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:ViewListResponse xmlns:ns1="urn:RegistrySystem" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:Array" ns2:arrayType="ns2:Array[13]">
<item xsi:type="ns2:Array" ns2:arrayType="xsd:anyType[2]">
<item xsi:type="xsd:string">IEI22202</item>
<item xsi:type="xsd:string">GUI</item>
</item>
......
<item xsi:type="ns2:Array" ns2:arrayType="xsd:anyType[2]">
<item xsi:type="xsd:string">IEI12301</item>
<item xsi:type="xsd:string">Robotics</item>
</item>
</return>
</ns1:ViewListResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>