|
I had some trouble getting this to work, so I made some modifications. First off, I replaced the use of SpringAxisServlet.java with the org.springframework.web.context.ContextLoaderListener from the spring api. This required a modification to SpringBeanRPCProvider.java (and will require modification of SpringBeanMsgProvider.java as well, but have not looked into that yet). Second, I was having trouble with the the axis servlet making calls to (java.lang.String, org.apache.axis.handlers.soap.SOAPService, org.apache.axis.MessageContext) with null MessageContexts, causing the webservice to error upon deployment. I addressed this by adding <parameter name="springBeanClass" value="class.of.springBean"/> to the wsdd and extending SpringBeanRPCProvider to read this. This may not be the most elegant solution (ideally this information could be gathered from the WebApplicationContext), but I could not find a way to access the ServletContext at the time that Axis called for this information. Thanks for the nice bits of code Mr. Czarniecki, I was trying to figure this out myself when I stumbled across this post. Thanks to the great Spring team as well, as far as I'm concerned, Axis+Spring seems to be the best way I've seen to author web services. Joshua, Do you have your deploy.wsdd file for the service available along with your web.xml for Axis? I'm new to Axis and i've been struggling with trying to get this to work. What would be great is if somebody posted a working example - pls pls??? -john Joshua, thanks for the help. I am trying to do this with Message style provider. I will let you know if i have any success. (and hopefully post a working example -jm Hi Joshua/ All, Is there any full blown spring-web services tutorial available that I can put my hands on. We're trying to use Spring framework in an Enterprise Portal project. Thanks much in advance. lkj I found an example of using document literal with Axis: check out the Pizza Calculator. -jm Still looking for a full blown spring web services tutorial! Any takers? Pointers. Thx. in advance. See Also Rod's latest book covers this - "... J2EE without EJB" Thanks for all your comments and support Joshua. Haven't had the time to check on this issue until now. I am curious though, we have had this solution working without any null MessageContexts for a number of months, so either we are doing something funny, or there are some more issues with axis that I am unaware of. Secondly, we wrote the axis integration in such a way so that it could co-operate nicely with a spring web application context loaded by the context listener much in the same way that Spring's own DispatcherServlet does, and in the same way that the Spring-Struts plug-in integration works. Therefore, you can have your common application services, DAOs, etc, loaded by the root web application context, and have axis specific end-points loaded by the axis integration, and still have services and DAOs injected into the endpoints. So I am not sure what the benefits are from your proposed integration model. I've actually implemented this somehwere late 2004 as well and didn't have the time yet to look at this. The solution I had was almost the same except for the fact that I provided a new style: SpringRPC and registered this without having to extend the AxisServlet. I can't find the code know however so I'll have to have another look at this. I think it's best to wait with something like this until Axis 1.2 is released. 1.2 will be dificult anyway so I'm moving this to 1.3 (for which I'd really like to have a look at this). I had a go with the code I ran into similar problems as Joshua. MsgContext is null. Fault - ; nested exception is: Could not find class for the service named: formRequestWS Mads, Hi Tom, Maybe I got something wrong. Here is my web.xml. <web-app> <listener> <servlet> <!-- Spring remoting --> <!-- Axis --> <servlet> <!-- <!-- Spring remoting --> <!-- Axis --> <servlet-mapping> <servlet-mapping> <!-- <!-- uncomment this if you want the admin servlet --> <session-config> <!-- currently the W3C havent settled on a media type for WSDL; <mime-mapping> </web-app> By the way. I'm using jboss 3.2.7, Axis 1.2.1 and jdk 1.3.1 I too was getting null MessageContexts Running this on: Tomcat 4.1.30, Axis 1.1 and Sun JDK 1.3.1_02 on Linux We are running this on both WindowsXP/jdk1.4.2/tomcat4.1.30 and Solaris/jdk1.4.2/SunOne7. One thing that I did note is that we are running axis (1.2beta 2107 May 19 2004) because we needed to add castor document marshalling/unmarshalling to axis. So, it may be that in axis 1.1 the MessageContext is null, but not in axis 1.2. Here is an abridged version of our web.xml. As you can see we run a Struts/Spring integration as well as axis in the same web app, so our Spring beans are configured from a number of xml files:
<?xml version="1.0"?> <!DOCTYPE web-app <web-app> <distributable></distributable> <context-param> <filter> <filter-mapping> <filter-mapping> <listener> <servlet> <servlet> <servlet-mapping> <servlet-mapping> <session-config> <welcome-file-list> <error-page> <error-page> <error-page> <taglib> <taglib> <taglib> <taglib> <taglib> <taglib> <taglib> <taglib> <taglib> <resource-ref> <resource-ref> <resource-ref> <resource-ref> <resource-ref> </web-app> D'oh. Just spotted that you are using axis 1.2.1 Mads. here is my web.xml: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app <web-app> <servlet> <!-- Axis --> <!-- Axis --> <servlet-mapping> <welcome-file-list> <!-- currently the W3C havent settled on a media type for WSDL; <mime-mapping> I tried the orginal java files (unmodified) and all worked!
Tom, is there a copyright and/or license to these source files? I need to check them into my subversion repository (http://scm.sipfoundry.org/rep/sipX THANKS!!! I finally got the NullPointer exception, however the _mod files caused me more grief related to NullPointers with ParameterDesc.getJavaType deep inside Axis so I just changed this one line Instead made the following edit to SpringBeanProvider.java:53 Douglas: I was getting the NullPointers when no SOAP message is posted. This happens when ?wsdl is accessed or when opening raw service URL with web browser (which is of little importance) I refactored code original code posted to store WebApplicationContext in the Axis Engine session. All works now. ServletContext would have been better, unfort. I couldn't get that to work in all cases for me. Code also available here: This may be a dumb comment, but the wsdd config for using this stuff is not clear. My settings: <service name="UserService" provider="java:RPC"> result in the following exception: 18:28:24,395 WARN [Types] The class foo.bar.svc.IUserServiceInternal does not contain a default constructor, which is a requirement for a bean class. The class cannot be converted into an xml schema type. An xml schema anyType will be used to define this class in the wsdl file. and a subsequent null pointer. This means that the implementation class of the interface is never injected into the UserWebService and that the public setter for the implementation is being exposed since it is trying to convert the interface that has been specified as an argument in my setter. Please include some sort of documentation on this feature for fools like me. Fileset of classes that Registers SpringRPC and SpringMsg as new providers Fileset of classes that Registers SpringRPC and SpringMsg as new providers Fileset of classes that Registers SpringRPC and SpringMsg as new providers I commited a new class fileset. This Adds Spring configurability to Axis through the commons-discovery plugin mechanism provided by Axis. If theese classes are in the classpath and the: org.apache.axis.deployment.wsdd.Provider file can be found in the classpath in /META-INF/services then a Spring managed Service can be added as <service name="PingPong" provider="java:SpringRPC"> or <service name="PingPong" provider="java:SpringMsg"> The advantage of this Type of injection is that I requires no setup from the user at all, just putting the I also uploaded A BeanHandler class. This class is to create Spring configured Handlers for axis Usage is <handler name="BeanAuthenticate" type="java:com.workingmouse.webservice.axis.BeanHandler"> This class is still a little crude and needs some proper Error Handling added, but It works My naming of parameters is a little inconsistent right now, and some code still needs to be Here's another way. It gets rid of server-config.wsdd, keeps the whole configuration in Spring, deploys and undeploys any bean directly as an Axis service (including ?wsdl generation), and needs no class path magic. I created an issue in Axis JIRA because the problem how to publish any object (not just a class) as a web service is not Spring specific, and neither is this solution. The folks at sipX seem to have found a new solution to the NPE bug - take a look at http://scm.sipfoundry.org/viewsvn/sipX/main/sipXconfig/web/src/com/workingmouse/webservice/axis/ As of Spring 2.5, there are no plans for special integration with Axis 1 anymore, so I'm closing this issue now. Juergen |
|||||||||||||||||||||||||||||||||||||||||||
For integration with apache axis, have a look at the javadoc in SpringBeanRPCProvider.java and SpringBeanMsgProvider.java