File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes problem by invoking web service with axis2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "problem by invoking web service with axis2" Watch "problem by invoking web service with axis2" New topic
Author

problem by invoking web service with axis2

xin sa
Greenhorn

Joined: May 02, 2007
Posts: 11
Hello, everybody, i have a erorr by the Invoking web service with axis2, plese help me!

the service code:
--------------------
public void estConnection(String user, String passwd) throws AxisFault
{
String connString = Const.getCONNECTIONSTRING();
if(connString == null)
{
throw new AxisFault("Unknown server defined in web.xml.");
}

SessionContext session = MessageContext.getCurrentMessageContext().getSessionContext();
session.getProperties().remove(Const.SESSIONUSER);
session.getProperties().remove(Const.SESSIONCUSTOMER);
Connection conn;
try
{
Class.forName(Const.DBDRIVERCLASS);
}
catch(ClassNotFoundException cnfe)
{
terminate();
throw new AxisFault("Oracle Driver-class not found.");
}
try
{
conn = DriverManager.getConnection(connString, user, passwd);
}
catch(SQLException sqle)
{
terminate();
throw new AxisFault("Connection as admin could not be established.\n" + connString + " User: " + user);
}
DBHandler dbHandler = new DBHandler();
try
{.....}
------------------------------------------------

the client side code:
-----------------------
private static EndpointReference targetEPR = new EndpointReference("http://"+endpoint()+"/axis2/services/SolverAdminService");

public void estConnection(String user, String passwd)throws RemoteException{

RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
options.setTo(targetEPR);
options.setAction("urn:estConnection");
serviceClient.setOptions(options);
QName opSet = new QName("http://services.solver.nx.wp.com/xsd", "estConncetion");
Object response = serviceClient.invokeBlocking(opSet,new Object[] {user,passwd });
if(response instanceof RemoteException)
{
throw (RemoteException)response;
}
}
----------------------

and if i run the client side package,there is always a erorr the compile is already passed.)
-----------

2007-05-29 12:25:24,180 ERROR org.apache.axis2.rpc.receivers.RPCMessageReceiver - Exception occurred while trying to invoke service method estConnection
-------------------------------------------------
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:116)
at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:39)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:144)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:279)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:116)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
----------------------------------------------
Caused by: java.lang.NullPointerException
-------------------------------------------
at com.wp.nx.solver.services.SolverAdminService.estConnection(SolverAdminService.java:65)
-------------
the line 65 is "session.getProperties().remove(Const.SESSIONUSER);" in the above service-side code.

help???
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42022
    
  64
Is "session" null, or "session.getProperties()" ?


Ping & DNS - my free Android networking tools app
xin sa
Greenhorn

Joined: May 02, 2007
Posts: 11
i think, that session is null.
have you any idears?
xin sa
Greenhorn

Joined: May 02, 2007
Posts: 11
Hi, I have found, that Session is null, and i added the following codes:

----------------------------------------------
public static SessionContext createSessionContext(MessageContext messageContext) {

HttpServletRequest request = (HttpServletRequest) messageContext.getProperty(
HTTPConstants.MC_HTTP_SERVLETREQUEST);
SessionContext sessionContext = null;

HttpSession httpSession = request.getSession(true);
if (httpSession != null) {
sessionContext =
(SessionContext) httpSession.getAttribute(Constants.SESSION_CONTEXT_PROPERTY);
if (sessionContext == null && httpSession.isNew()) {
String cookieValueString = httpSession.getId();
sessionContext = new SessionContext(null);
sessionContext.setCookieID(cookieValueString);
httpSession.setAttribute(Constants.SESSION_CONTEXT_PROPERTY, sessionContext);
messageContext.setSessionContext(sessionContext);
messageContext.setProperty("SessionId", cookieValueString);
}
}
return sessionContext;
}

--------------------------------


SessionContext session = createSessionContext(MessageContext.getCurrentMessageContext());

------------------------------
So this time the session(or SessionContext) is not null, ha, that's good, buuuuut~~, the "session.getProperties()" is null, oooohhhhh.....
has anyone idears? help me
 
GeeCON Prague 2014
 
subject: problem by invoking web service with axis2