请问JAXM创建MessageFactory的问题

03-08-22 llystart
我用下面语句实例化MessageFactory:

MessageFactory messageFactory=MessageFactory.newInstance();

一、当引入jaxm.jar时,编译通过,但运行时出错:

javax.xml.soap.SOAPException: Unable to create message factory for SOAP: com.sun.xml.messaging.soap.MessageFactoryImpl

at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:87)

at SoapClient.main(SoapClient.java:9)

Exception in thread "main"

二、如果引入WebLogic安装目录下\weblogic700\server\lib里的weblogic.jar和webservice.jar,则编译运行均正常。

不知是怎么回事?

bruce
2003-08-22 10:20
谈谈我的看法:

newInstance()是一种动态写法,编译时java并不能查出要真正实例化装入的对象,但在运行时这个newInstance()实际要实例化要装入的对象,并不在类路径里,系统找不到,就出Exception了。

llystart
2003-08-22 10:52
那请问用JAXM开发SOAP应用需要引入那几个包才能正常运行啊?

我现在创建SOAPConnection实例:

SOAPConnection soapConnection=SOAPConnection.newInstance();

引入WebLogic的那两个包时:

Error #: 300 : method newInstance() not found in class javax.xml.soap.SOAPConnection at line 17, column 50

如果在引入jaxm.jar,SOAPConnection 没有问题,但是在运行时就又出现了:

javax.xml.soap.SOAPException: Unable to create message factory for SOAP: com.sun.xml.messaging.soap.MessageFactoryImpl

at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:87)

at JAXMAttachments.main(JAXMAttachments.java:9)

Exception in thread "main"

到底需要哪些包啊,太烦人了!

猜你喜欢