Topic: 配制 <service-ref> 用 JNDI 访问 Web Services 的问题。

  Print this page

1.配制 <service-ref> 用 JNDI 访问 Web Services 的问题。 Copy to clipboard
Posted by: accason
Posted on: 2004-10-18 22:56

Dear All,

  使用 Sun Java™ System Application Server Platform Edition 8 2004Q4 Beta 作为应用服务器。
  使用 Axis 生成 Stub 。
  使用 Deployment Tool for Sun Java™ System Application Server Platform Edition 8 来打包部署。

  我开发了一个 Web Service 并部署成功,使用普通 Java 类,通过类似如下的语法可以调用成功:
  String portAddress = "http://localhost:8080/my-web/BookQuoteService";
  BookQuote bookQuote = new BookQuoteServiceLocator().getBookQuotePort(new URL(portAddress));
  System.out.println(bookQuote.getBookPrice("accason"));
  
  但我想在 JSP/Servlet 中使用 JNDI 来调用该 Web Service ,所以在 web.xml 中配制了 <service-ref> 元素。
  在 JSP/Servlet 中如下调用:
  InitialContext initialContext = new InitialContext();
  BookQuoteService bookQuoteService = (BookQuoteService) initialContext.lookup("java:comp/env/service/BookQuoteService");
  BookQuote bookQuote = bookQuoteService.getBookQuotePort();
  float price = bookQuote.getBookPrice("accason");

  在运行时,BookQuote bookQuote = bookQuoteService.getBookQuotePort() 一句报错:
  java.lang.IllegalArgumentException: object is not an instance of declaring class
  ...
  $Proxy15.getBookQuotePort(Unknown Source)
  org.apache.jsp.wsTestJSP_jsp._jspService(wsTestJSP_jsp.java:53)
  ...
  
  我查看了 bookQuoteService 这时的类型,好像是这个类:
  com.sun.enterprise.webservice.ServiceInvocationHandler@1c28c8
  我搞不懂,为什么不是 BookQuoteService ?
  
  有人用 JNDI 调用 Web Service 成功过吗?怎么做的?是我的代码有问题还是配制有问题?请指点一下。万分感激!
  
  谢谢!

Regards,
accason
accason@tom.com

2.Re:配制 <service-ref> 用 JNDI 访问 Web Services 的问题。 [Re: accason] Copy to clipboard
Posted by: liuxuec
Posted on: 2004-11-03 14:56

用这个类ServiceInvocationHandler是使用了动态代理,这个不是错

3.Re:配制 <service-ref> 用 JNDI 访问 Web Services 的问题。 [Re: accason] Copy to clipboard
Posted by: didongusa
Posted on: 2004-11-26 12:16

To accason:

The <service-ref> belongs to J2EE 1.4. it looks like your application server doesn't support it. Oracle has a beta version of OC4J 10g, and it supports this kind of deployment. The J2EE 1.4 compatible release would be two months later.
--------------------
BookQuote bookQuote = bookQuoteService.getBookQuotePort()

java.lang.IllegalArgumentException: object is not an instance of declaring class
--------------------------
I gusee the application server doesn't know this ref.

Most application server handle SOAP request by using vendor servlet.

If you want to refer the web services dynamically, usually you need set up UDDI server.

I conclude that you jump up this train too early, but this JAX-RPC vendors are building the tools.

Take care.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923