Re: Webservice context is null (not injected)

BALARAMA THAVANATI <[email protected]>
Newsgroups gmane.text.xml.axis.user
Message-ID <[email protected]>
A small correction in the code, here are the artifacts again:
--------------------------------------------------
following are my artifacts used
(1)
 HelloWorld interface
_______________________
package com.bal.service;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.jws.soap.SOAPBinding.Use;

@WebService
@SOAPBinding(style=Style.DOCUMENT, use = Use.LITERAL)
public interface HelloWorld {

@WebMethod
public String echo(String input);
}
_____________________________________________
(2) HelloWorldImpl
_______
package com.bal.service;

import javax.jws.WebService;
//corrected the package name
@WebService(endpointInterface = "com.bal.service.HelloWorld") 
public class HelloWorldImpl implements HelloWorld {

    @Resource WebServiceContext ctx;
    
    @Override
    public String echo(String input) {
        
       
 // ctx is NULL here!!
        MessageContext mCtx = ctx.getMessageContext();
        
        return "received "+ input ;
    }

}
__________________________________________
(3) services.xml
________
<serviceGroup>
    <service name="HelloService">
    <Description>Hello web Service</Description>
    <parameter name="ServiceClass">com.bal.service.HelloWorldImpl</parameter>    
        <messageReceivers>
   
         <messageReceiver 
mep="http://www.w3.org/2004/08/wsdl/in-only" 
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
            <messageReceiver
 mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
        </messageReceivers>
    </service>
</serviceGroup>
 




________________________________
 From: BALARAMA THAVANATI <[email protected]>
To: "[email protected]" <[email protected]> 
Sent: Wednesday, December 26, 2012 11:55 AM
Subject: Webservice context is null (not injected)
 

 Hi
 I have created an .aar file and dropped in the WEB-INF/services directory of axis2 (1.6.2) war file. I deployed this to jboss 5.1 app server

 I used the  annotation "@Resource WebServiceContext" in the impl, but  am not getting the WebServiceContext injected into the web service implementation class.
 The line where I try to use the context is throwing NullPointerException

--------------------------------------------------
following are my artifacts used
(1)
 HelloWorld interface
_______________________
package com.bal.service;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.jws.soap.SOAPBinding.Use;

@WebService
@SOAPBinding(style=Style.DOCUMENT, use = Use.LITERAL)
public interface HelloWorld {

@WebMethod
public String echo(String input);
}
_____________________________________________
(2) HelloWorldImpl
_______
package com.bal.service;

import javax.jws.WebService;

@WebService(endpointInterface = "com.oneshield.service.HelloWorld")
public class HelloWorldImpl implements HelloWorld {

    @Resource WebServiceContext ctx;
    
    @Override
    public String echo(String input) {
        
       
 // ctx is NULL here!!
        MessageContext mCtx = ctx.getMessageContext();
        
        return "received "+ input ;
    }

}
__________________________________________
(3) services.xml
________
<serviceGroup>
    <service name="HelloService">
    <Description>Hello web Service</Description>
    <parameter name="ServiceClass">com.bal.service.HelloWorldImpl</parameter>    
        <messageReceivers>
            <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
            <messageReceiver
 mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
        </messageReceivers>
    </service>
</serviceGroup>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.