A simple interface
package test;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.Holder;
@WebService(serviceName = "Foo")
public interface Foo {
boolean bar(String inStr, @WebParam(mode = WebParam.Mode.INOUT)
Holder<String> outStr);
}
and the implementation
package test;
import javax.jws.WebService;
import javax.xml.ws.Holder;
@WebService(endpointInterface = "test.Foo")
public class FooImpl implements Foo {
public boolean bar(String inStr, Holder<String> outStr) {
outStr.value = "Hello " + inStr;
System.out.println("inStr: " + inStr);
System.out.println("outStr: " + outStr.value);
return true;
}
}
use org.springframework.web.servlet.DispatcherServlet and org.codehaus.xfire.spring.remoting.XFireExporter to export the service.
when invoked, error occured:
ERROR-[2006-07-12 14:13:48,903] Fault occurred!
java.lang.NullPointerException
at org.codehaus.xfire.aegis.type.basic.HolderType.readObject(HolderType.java:54)
at org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:94)
at org.codehaus.xfire.service.binding.AbstractBinding.read(AbstractBinding.java:208)
at org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:50)
at org.codehaus.xfire.jaxws.JAXWSOperationBinding.readMessage(JAXWSOperationBinding.java:148)
at org.codehaus.xfire.jaxws.JAXWSBinding.readMessage(JAXWSBinding.java:55)
at org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:110)
at org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:61)
at org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38)
at org.codehaus.xfire.transport.http.XFireServletController.invoke(XFireServletController.java:261)
at org.codehaus.xfire.transport.http.XFireServletController.doService(XFireServletController.java:120)
at org.codehaus.xfire.spring.remoting.XFireServletControllerAdapter.handleRequest(XFireServletControllerAdapter.java:63)
at org.codehaus.xfire.spring.remoting.XFireExporter.handleRequest(XFireExporter.java:44)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:797)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:727)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:360)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:154)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)
at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:106)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:178)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:389)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:507)
at com.caucho.util.ThreadPool.run(ThreadPool.java:433)
at java.lang.Thread.run(Thread.java:595)
Here is my environment settings:
Application server: Weblogic 8.1 sp6
JDK: jrockit-R27.1.0-jdk1.4.2_12 (J2SE 1.4.2)
xfire 1.2.6
Spring 2.0.2
Hibernate 3.2.2ga
I am trying to configure a service method to use a out/inout parameter. I am testing that with the book example. My server starts without any problems, but when I start my client test class, I get the following error:
java.lang.NullPointerException:
at org.codehaus.xfire.aegis.type.basic.HolderType.readObject(HolderType.java:54)
at org.codehaus.xfire.aegis.AegisBindingProvider.readParameter(AegisBindingProvider.java:169)
at org.codehaus.xfire.service.binding.AbstractBinding.read(AbstractBinding.java:206)
at org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:51)
at org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:64)
at org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38)
at org.codehaus.xfire.transport.http.XFireServletController.invoke(XFireServletController.java:304)
at org.codehaus.xfire.transport.http.XFireServletController.doService(XFireServletController.java:129)
at org.codehaus.xfire.spring.remoting.XFireServletControllerAdapter.handleRequest(XFireServletControllerAdapter.java:67)
at org.codehaus.xfire.spring.remoting.XFireExporter.handleRequest(XFireExporter.java:48)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:820)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:755)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:360)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at com.psws.patientportal.dmtool.audit.AuditFilter.doFilter(AuditFilter.java:31)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:173)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7053)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
Here are my classes and config files:
public interface BookService
{
public Book[] getBooks();
public Book findBook(String isbn) throws BookException;
public Map getBooksMap();
public Book changeAuthor(String author, Holder bookHolder) throws BookException;
}
public class BookServiceImpl implements BookService
{
private Book onlyBook;
public BookServiceImpl()
{ onlyBook = new Book(); onlyBook.setAuthor("Dan Diephouse"); onlyBook.setTitle("Using XFire"); onlyBook.setIsbn("0123456789"); }public Book[] getBooks()
{ ... }public Book findBook(String isbn) throws BookException
{ ... }public Map getBooksMap() { ... }
public Book changeAuthor(String author, Holder bookHolder) throws BookException { Book newBook = new Book(); newBook.setAuthor(author); newBook.setIsbn(onlyBook.getIsbn()); newBook.setTitle(onlyBook.getTitle()); bookHolder.setValue(newBook); return newBook; }
}
<!-- BookService.aegis.xml -->
<mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xfire.codehaus.org/schemas/1.0/mapping.xsd">
<mapping>
<method name="getBooksMap">
<return-type mappedName="books" keyType="java.lang.String" componentType="com.psws.patientportal.test.xfire.bo.Book" />
</method>
<method name="changeAuthor">
<parameter index="0" mappedName="author" typeName="java.lang.String"/>
<parameter index="1" mappedName="book" componentType="com.psws.patientportal.test.xfire.bo.Book"/>
<return-type mappedName="newBook" componentType="com.psws.patientportal.test.xfire.bo.Book" />
</method>
</mapping>
</mappings>
// Test class
public class xfireClientApiTest {
public static void main(String[] args) throws Exception { ObjectServiceFactory serviceFactory = new ObjectServiceFactory(); XFireProxyFactory proxyFactory = new XFireProxyFactory(); Service bookServiceModel = serviceFactory.create(BookService.class); BookService bookService = (BookService) proxyFactory.create(bookServiceModel, "http://localhost:7777/patient/xfire/BookService"); Holder bookHolder = new Holder(); // bookHolder.setValue(foundBook); Book newBook = bookService.changeAuthor("Philip St-Pierre", bookHolder); newBook.print(); }
}
<!-- xfire-servlet.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- START SNIPPET: xfire -->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/BookService">
<ref bean="book"/>
</entry>
</map>
</property>
</bean>
<!-- Declare a parent bean with all properties common to both services -->
<bean id="book" class="org.codehaus.xfire.spring.remoting.XFireExporter">
<property name="serviceFactory">
<ref bean="xfire.serviceFactory"/>
</property>
<property name="xfire">
<ref bean="xfire"/>
</property>
<property name="serviceBean">
<ref bean="bookService"/>
</property>
<property name="serviceClass">
<value>com.psws.patientportal.test.xfire.service.BookService</value>
</property>
</bean>
<!-- END SNIPPET: xfire -->
</beans>
The issue is supposed to be fixed right? Is it? Or did I miss any thing? The documentation doesn't say much on how to use out/inout parameters.
Thank you
Phil