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 Chris Tinning <ch...@mclarensoftware.com> on 2008/12/01 10:25:29 UTC
RE: Client stubs NullPointer Exception
Thanks Marc,
I should have been clearer. Yes I've used the Ant task which basically
doe the same work as the command line and the code shows how I use the
classes in my client.
The serviceStub class in my example is equivalent to the
"com.my.package.MyServicesStub" class you talk about.
-----Original Message-----
From: Marc F. [mailto:marc.musico@gmail.com]
Sent: 29 November 2008 13:20
To: axis-user@ws.apache.org
Subject: RE: Client stubs NullPointer Exception
Chris Tinning wrote:
>
> This is my code -
> Setup -
>
> ConfigurationContext config
>
=ConfigurationContextFactory.createConfigurationContextFromFileSystem(nu
ll,
> AXIS2_CONFIG_FILE_LOCATION);
> // serviceUrl of the form http://host:8080/app/services/session
> serviceStub = new SessionServiceStub( config, serviceUrl);
>
>
> And later calling the service -
>
> GetAvailableConnectionsDocument request =
> GetAvailableConnectionsDocument.Factory.newInstance();
> GetAvailableConnectionsResponse response =
> serviceStub.getAvailableConnections( request );
>
> The call to getAvailableConnections results in the NullPointer. As far
as
> I can see this is the same as in the documentation. It is loading the
> axis2.config file as I've had to comment out the addressing module
from
> that - could this be the problem? I am using the supplied axis2.xml
with
> only that change, I've also tried without supplying the config (ie.
new
> SessionServiceStub(serviceUrl) ) and got the same error.
>
Well, I am not sure if your code is valid or not (is your code from
Axis2 or
Axis1?), but I am sure that what you do is completely different from
what I
do. I access and use a wsdl webservice. To do such a thing, I have to
develop a XML Beans client. Then, first run the following command, from
the
Axis2 command line tools:
<AXIS2_HOME>/bin/wsdl2java.{bat,sh} -o output -p com.my.package -d
xmlbeans
-t -ss -sd -g -uri http://www.com.site/webservices/MyServices?wsdl
Where "http://www.com.site/webservices/MyServices?wsdl" is the location
of a
wsdl.
Finally, I just have to use the auto-generated client stub class, that,
running the command above, is "com.my.package.MyServicesStub" class (of
course, you can refactor the code, renaming the class name, for
example).
--
View this message in context:
http://www.nabble.com/Client-stubs-NullPointer-Exception-tp20721127p2074
6959.html
Sent from the Axis - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
________________________________________________________________________
This e-mail has been scanned for viruses, however, No liability is accepted for any viruses contained in this message or any of its attachments and it is the recipient?s liability to scan this message and its attachment for the same.
________________________________________________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
RE: Client stubs NullPointer Exception
Posted by "Marc F." <ma...@gmail.com>.
Chris Tinning wrote:
>
> This is my code -
> Setup -
>
> ConfigurationContext config
> =ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
> AXIS2_CONFIG_FILE_LOCATION);
> // serviceUrl of the form http://host:8080/app/services/session
> serviceStub = new SessionServiceStub( config, serviceUrl);
>
>
> And later calling the service -
>
> GetAvailableConnectionsDocument request =
> GetAvailableConnectionsDocument.Factory.newInstance();
> GetAvailableConnectionsResponse response =
> serviceStub.getAvailableConnections( request );
>
> The call to getAvailableConnections results in the NullPointer. As far as
> I can see this is the same as in the documentation. It is loading the
> axis2.config file as I've had to comment out the addressing module from
> that - could this be the problem? I am using the supplied axis2.xml with
> only that change, I've also tried without supplying the config (ie. new
> SessionServiceStub(serviceUrl) ) and got the same error.
>
I am re-replying because I suspect you are not seeing the last update I did
in my last reply (I don“t know how exactly this forum works yet). Here I
go... read below:
Is really the SessionServiceStub a XML Beans client stub, generated from
Axis2? Did you modify the default code of the auto-generated
SessionServiceStub class?
In the following line:
GetAvailableConnectionsDocument request =
GetAvailableConnectionsDocument.Factory.newInstance();
Instead of doing that, rename the "request" variable to "requestDocument"
(just to make things more clear):
GetAvailableConnectionsDocument requestDocument =
GetAvailableConnectionsDocument.Factory.newInstance();
Next, you also have to define the instance of the GetAvailableConnections
class, that would be something like this:
GetAvailableConnections request =
GetAvailableConnections.Factory.newInstance();
And then you have to pass this "request" to the "requestDocument", that
would be something like this:
requestDocument.setAvailableConnections(request);
In the following line:
GetAvailableConnectionsResponse response =
serviceStub.getAvailableConnections( request );
I do not know how you wrote the method getAvailableConnections (how did you
create the SessionServiceStub class?), I even doubt that your code compile
(post the full code, please, or upload your code in a zip file), but,
instead of calling the webservice like that, you should call this way:
GetAvailableConnectionsResponseDocument responseDocument =
serviceStub.getAvailableConnections( requestDocument);
You should have, in your client stub class (supposedly, the
SessionServiceStub class), a method that returns a
GetAvailableConnectionsResponseDocument , not a
GetAvailableConnectionsResponse.
Finally, to obtain a GetAvailableConnectionsResponse, you have to do this:
GetAvailableConnectionsResponse response =
responseDocument.getAvailableConnectionsResponse();
This "response" object is an instance of GetAvailableConnectionsResponse in
which you have all the things you want.
--
View this message in context: http://www.nabble.com/Client-stubs-NullPointer-Exception-tp20721127p20782028.html
Sent from the Axis - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org