Aaron,

I'm guessing that you have your own beans that you want to use for your
own purposes. Why not have them injected into your service class? That
would be the preferred Spring style. Glen's reference to the
'Spring-aware' APIs is your other alternative. 

> -----Original Message-----
> From: Aaron Yyyy [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, November 14, 2007 7:49 PM
> To: [email protected]
> Subject: Spring Context
> 
> I am new to CXF and I am trying to use it with Spring.
> 
> What is the best way to obtain the ApplicationContext in a 
> class that was generated by the wsdl2java utility? I 
> currently have the applicationContext.xml file in the WEB-INF 
> directory but I don't know how to obtain the context. Since 
> the application is packaged in a war, I would like to obtain 
> the context using WebXMLApplicationContext but I don't know 
> how to get the ServletContext first.
> 
> Here is the interface generated by CXF:
> =========================================
> package com.example;
> 
> import javax.jws.WebParam.Mode;
> import javax.jws.WebParam;
> import javax.jws.WebService;
> import javax.jws.soap.SOAPBinding.Style; import 
> javax.jws.soap.SOAPBinding; import javax.jws.WebMethod; 
> import javax.jws.WebResult;
> 
> /**
>  * This class was generated by Apache CXF (incubator) 2.0.3-incubator
>  * Wed Nov 14 14:50:54 PST 2007
>  * Generated source version: 2.0.3-incubator
>  *
>  */
> 
> @WebService(targetNamespace = "http://example.com/soap";, name 
> = "HelloWorldPortType") @SOAPBinding(parameterStyle = 
> SOAPBinding.ParameterStyle.BARE)
> 
> public interface HelloWorldPortType {
> 
>     @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
>     @WebResult(targetNamespace = 
> "http://example.com/soap/types";, partName = "body", name = 
> "HellowWorldResponse")
>     @WebMethod(action = "HellowWorld", operationName = "HellowWorld")
>     public com.example.soap.types.HellowWorldResponse hellowWorld(
>         @WebParam(targetNamespace = 
> "http://example.com/soap/types";, partName = "body", name = 
> "HellowWorldRequest")
>         com.example.soap.types.HellowWorldRequest body
>     );
> }
> 
> 
> Here is my implementation class:
> ==================================
> package com.example;
> 
> import java.util.logging.Logger;
> 
> import javax.jws.WebMethod;
> import javax.jws.WebParam;
> import javax.jws.WebResult;
> import javax.jws.soap.SOAPBinding;
> 
> import com.example.soap.HellowWorldPortType;
> 
> @javax.jws.WebService(portName = "HelloWorldPort", 
> serviceName = "HelloWorldService", 
>                       targetNamespace = "http://example.com/soap";, 
>                       endpointInterface = 
> "com.example.soap.HellowWorldPortType")
> @javax.xml.ws.BindingType(value = 
> "http://www.w3.org/2003/05/soap/bindings/HTTP/";)                  
> public class HellowWorldImpl implements HellowWorldPortType {
> 
>     private static final Logger LOG = 
>         
> Logger.getLogger(HellowWorldImpl.class.getPackage().getName());
>     
>     @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
>     @WebResult(targetNamespace = 
> "http://example.com/soap/types";, partName = "body", name = 
> "HellowWorldResponse")
>     @WebMethod(action = "HellowWorld", operationName = "HellowWorld")
>     public com.example.soap.types.HellowWorldResponse helloWorld(
>         @WebParam(targetNamespace = 
> "http://example.com/soap/types";, partName = "body", name = 
> "HellowWorldRequest")
>         com.example.soap.types.HellowWorldRequest body
>     ){
>     
>         //how to I access Spring Application context from 
> here when I don't have access to servletContext???
>         XmlWebApplicationContext ctx = new XmlWebApplicationContext();
>             ctx.setConfigLocations(files);
>             ctx.setServletContext(servletContext);
>             ctx.refresh();
> 
>             ctx.getBean("hello");
> 
>         HellowWorldResponse hwr = new HellowWorldResponse();
>         
>         return hwr;
>     }
> }
>        
> ---------------------------------
> Never miss a thing.   Make Yahoo your homepage.
> 

Reply via email to