You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by BALARAMA THAVANATI <bt...@verizon.net> on 2012/12/26 17:58:43 UTC
Re: Webservice context is null (not injected)
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 <bt...@verizon.net>
To: "java-user@axis.apache.org" <ja...@axis.apache.org>
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>