急求这段SOAP JAVA程序的解救方法,拜托高手救命阿

flutina 2003-08-21 06:08:12
我用这段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>
...全文
58 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
flutina 2003-08-23
  • 打赏
  • 举报
回复
这是我写的,错的,帮我看看是哪错了吧
deploymentdescriptor.xml

- <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment" id="urn:RegistrySystem">
- <isd:provider type="java" scope="Application" methods="CheckUandP GetStudentPInfo SetStudentPInfo ViewList ChangeNP">
<isd:java class="samples.RS.checkData" static="false" />
</isd:provider>
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
- <isd:mappings>
<isd:map encodingStyle="http://xml.apache.org/xml-soap/literalxml" xmlns:x="urn:RegistrySystem" qname="x:pinfo" javaType="org.w3c.dom.Element" java2XMLClassName="org.apache.soap.encoding.literalxml.XMLParameterSerializer" xml2JavaClassName="org.apache.soap.encoding.literalxml.XMLParameterSerializer" />
- <complexType name="ArrayofObject">
- <complexContent>
<restriction base="SOAP-ENC:arrayType" arrayType="xsd:Object[]" />
</complexContent>
</complexType>
</isd:mappings>
</isd:service>
flutina 2003-08-23
  • 打赏
  • 举报
回复
阿,对不起大家,我前面给错了。不好意思,2台机器弄混了。现在的问题出来了,应该是MAPPING错了,但正确的应该是什么阿.......!!!!!

C:\Tomcat\webapps\soap\WEB-INF\classes\samples\RS>deploy
This test assumes a server URL of http://localhost:8080/soap/servlet/rpcrouter
Deploying the Conversation service...
.
Verify that it's there
Deployed Services:
urn:RegistrySystemT
urn:RegistrySystem
.
start to logon
here
[SOAPException: faultCode=SOAP-ENV:Client; msg=No mapping found for 'http:/
/schemas.xmlsoap.org/soap/encoding/:Array' using encoding style 'http:
//schemas.xmlsoap.org/soap/encoding/'.; targetException=java.lang.IllegalAr
gumentException: No mapping found for 'http://schemas.xmlsoap.org/soap/encoding/
:Array' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.]
java.lang.NullPointerException
at samples.RS.viewcourselist.init(viewcourselist.java:53)
at samples.RS.studentindex.actionPerformed(studentindex.java:104)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
64)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1817)

flutina 2003-08-23
  • 打赏
  • 举报
回复
奋战了几天还是一头雾水,谢谢大家多帮帮我吧

C:\Tomcat\webapps\soap\WEB-INF\classes\samples\RS>deploy
This test assumes a server URL of http://localhost:8080/soap/servlet/rpcrouter
Deploying the Conversation service...
.
Verify that it's there
Deployed Services:
urn:RegistrySystem
.
start to logon
here
fail to build call
java.lang.NullPointerException
at samples.RS.viewcourselist.init(viewcourselist.java:53)
at samples.RS.studentindex.actionPerformed(studentindex.java:104)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
64)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1817)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5134)
at java.awt.Component.processEvent(Component.java:4931)
at java.awt.Container.processEvent(Container.java:1566)
at java.awt.Component.dispatchEventImpl(Component.java:3639)
at java.awt.Container.dispatchEventImpl(Container.java:1623)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
at java.awt.Container.dispatchEventImpl(Container.java:1609)
at java.awt.Window.dispatchEventImpl(Window.java:1590)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

C:\Tomcat\webapps\soap\WEB-INF\classes\samples\RS>java samples.RS.log http://loc
alhost:9000/soap/servlet/rpcrouter
here
!
java.lang.NullPointerException
at samples.RS.viewcourselist.init(viewcourselist.java:53)
at samples.RS.studentindex.actionPerformed(studentindex.java:104)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
64)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1817)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5134)
at java.awt.Component.processEvent(Component.java:4931)
at java.awt.Container.processEvent(Container.java:1566)
at java.awt.Component.dispatchEventImpl(Component.java:3639)
at java.awt.Container.dispatchEventImpl(Container.java:1623)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
at java.awt.Container.dispatchEventImpl(Container.java:1609)
at java.awt.Window.dispatchEventImpl(Window.java:1590)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
lcl101 2003-08-23
  • 打赏
  • 举报
回复
你把错误信息全部贴出来吧 看是在那个类里面出错了 如果是在Call 类中 那就说明是的参数给的不够
zhang21cnboy 2003-08-21
  • 打赏
  • 举报
回复
url 有问题!!!!!

cxhz_cn 2003-08-21
  • 打赏
  • 举报
回复
环境~~????

Apache Soap+tomcat的版本?

我估计你Deploy web Service的时候有问题
flutina 2003-08-21
  • 打赏
  • 举报
回复
我的tomcat 4.1.24
Soap2.4

这其实是一大个程序的一部分,是检索所有的课程
而其他部分比如登陆,和检索成员信息都可以工作。所以应该不会是DEPLOY的问题吧——不确定中

URL的问题我也测试了,传输过去的并没有问题

其他方面呢 我把我的DEPLOY的文件附上,大家帮我看看吧


deploymentdescriptor.xml

- <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment" id="urn:RegistrySystem">
- <isd:provider type="java" scope="Application" methods="CheckUandP GetStudentPInfo SetStudentPInfo ViewList ChangeNP">
<isd:java class="samples.RS.checkData" static="false" />
</isd:provider>
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
- <isd:mappings>
<isd:map encodingStyle="http://xml.apache.org/xml-soap/literalxml" xmlns:x="urn:RegistrySystem" qname="x:pinfo" javaType="org.w3c.dom.Element" java2XMLClassName="org.apache.soap.encoding.literalxml.XMLParameterSerializer" xml2JavaClassName="org.apache.soap.encoding.literalxml.XMLParameterSerializer" />
- <complexType name="ArrayofObject">
- <complexContent>
<restriction base="SOAP-ENC:arrayType" arrayType="xsd:Object[]" />
</complexContent>
</complexType>
</isd:mappings>
</isd:service>

deploy.cmd
@echo off
echo This test assumes a server URL of http://localhost:8080/soap/servlet/rpcrouter
echo Deploying the Conversation service...
java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter deploy DeploymentDescriptor.xml
echo .
echo Verify that it's there
java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter list
echo .
echo start to logon

java samples.RS.log http://localhost:8080/soap/servlet/rpcrouter

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧