• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem by invoking web service with axis2

 
xin sa
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is "session" null, or "session.getProperties()" ?
 
xin sa
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think, that session is null.
have you any idears?
 
xin sa
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic