aspose file tools*
The moose likes Web Services and the fly likes NullPointerException when calling a web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "NullPointerException when calling a web service" Watch "NullPointerException when calling a web service" New topic
Author

NullPointerException when calling a web service

Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 212
I am getting a null pointer exception, when calling a web service.

I had generated the java code using

C:\jwsdp-1.4\jaxrpc\bin\wscompile.bat -gen:client config.xml -keep

Config.xml is as follows




The stack trace is as follows



Does any of you guys have seen such an exception before?

When i went into the file

at external.cashin.wsdl.CMSPaymentService_PortType_Stub.enquire(CMSPaymentService_PortType_Stub.java:54)

This is a class file which was autogenerated, I have not coded anything in it.

What could be the reason of this exception? Any clues.
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1031
    
    5

Have you validated your WSDL file CMSPaymentService2.wsdl?
Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 212
I have not validated my wsdl. But could there be a problem with the wsdl?

How can a wsdl be validated?

Well there was no XML-malformedness that I could notice.

James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1031
    
    5

Yogesh

Could you post a listing of WSDL file? Is it against the 1.1 standard?

If you have eclipse, you may be interested in this:

http://wiki.eclipse.org/Using_the_WSDL_Validator_Outside_of_Eclipse
Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 212
Is there some online validator of wsdl file?
I do not have eclipse installed in office.

Where can I see the wsdl listing? I couldn't find it in the header of wsdl.


.
.
.
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1031
    
    5

I meant could you post the entire contents of your WSDL file.
Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 212


I created a local web service on my machine which is running on netbeans.
And
I have replaced http://www.abc.com with http://localhost:8080
before generating the java code.

James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1031
    
    5

Instead of

wscompile.bat -gen:client config.xml -keep

Try this:

wscompile.bat -gen:client config.xml -keep -Djavax.xml.soap.MessageFactory=com.sun.xml.messaging.saaj.soap.MessageFactoryImpl

You may need to ensure that MessageFactoryImpl is on your classpath.

I found more info on your exception here

Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 212
C:\dummy>set JAVA_HOME = C:\j2sdk1.4.0

C:\dummy>C:\jwsdp-1.4\jaxrpc\bin\wscompile.bat -gen:client config.xml -keep -Djavax.xml.soap.MessageFactory=com.sun.xml.messaging.saaj.soap.MessageFactoryImpl
error: -Djavax.xml.soap.MessageFactory is an invalid option or argument
Usage: wscompile [options] configuration_file

C:\dummy>C:\jwsdp-1.4\jaxrpc\bin\wscompile -help

Usage: wscompile [options] configuration_file

where [options] include:
-classpath <path> specify where to find input class files
-cp <path> same as -classpath <path>
-d <directory> specify where to place generated output files
-define define a service
-f:<features> enable the given features (see below)
-features:<features> same as -f:<features>
-g generate debugging info
-gen same as -gen:client
-gen:client generate client artifacts (stubs, etc.)
-gen:server generate server artifacts (ties, etc.)
-help display help
-source <version> generate code for the specified JAXRPC SI version.
supported versions are: 1.0.1, 1.0.3, 1.1, 1.1.1 and
1.1.2(default)
-httpproxy:<host>:<port> specify a HTTP proxy server (port defaults to 8080)
-import generate interfaces and value types only
-keep keep generated files
-model <file> write the internal model to the given file
-nd <directory> specify where to place non-class generated files
-O optimize generated code
-s <directory> specify where to place generated source files
-verbose output messages about what the compiler is doing
-version print version information
-mapping <file> write the 109 mapping file to the given file
[failed to localize] sec.usage.options

Exactly one of the -import, -define, -gen options must be specified.

The -f option requires a comma-separated list of features.

Supported features (-f):
datahandleronly always map attachments to the DataHandler type
documentliteral use document literal encoding
rpcliteral use rpc literal encoding
explicitcontext turn on explicit service context mapping
infix:<name> specify an infix to use for generated ties
and serializers
infix=<name> same as infix:<name> (not on Windows)
jaxbenumtype map anonymous enumeration to its base type.
nodatabinding turn off data binding for literal encoding
noencodedtypes turn off encoding type information
nomultirefs turn off support for multiple references
norpcstructures do not generate RPC structures (-import only)
novalidation turn off full validation of imported WSDL documents
resolveidref resolve xsd:IDREF
searchschema search schema aggressively for subtypes
serializeinterfaces turn on direct serialization of interface types
strict generate code strictly compliant with the JAXRPC
1.1 specification
useonewayoperations allow generation of one-way operations
wsi enable WSI-Basic Profile features (for
document/literal and rpc/literal)
unwrap enable unWrapping of document/literal
wrapper elements in wsi mode
donotoverride donot regenerate the classes
donotunwrap disable unWrapping of document/literal
wrapper elements in wsi mode (Default)

Internal options (unsupported):
-Xdebugmodel:<file> write a readable version of the model to a file
-Xprintstacktrace print exception stack traces
-Xserializable generate value types that implement Serializable int
erface

Examples:
wscompile -gen -classpath lib/foo.jar;lib/bar.jar -d generated config.xml
wscompile -gen -f:infix:Name -d generated config.xml
wscompile -define -f:nodatabinding -f:novalidation config.xml
wscompile -import -f:explicitcontext config.xml
Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 212
-D is not a valid option in wscompile.
Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 212
When I write a dummy web service using the same WSDL file using NetBeans.

And I wrote a client that invokes the method of that web service, it is able to invoke the method.

But, When I try to invoke the same web service method from JDeveloper, it is giving me the exception.


There are few differences in the environment.
1) The java version that is being used by Netbeans is 1.6
2) The classes that are generated by NetBeans for client are different than those which are generated by wscompile.
3) The classes generated by Netbeans has annotations, while the one generated by wscompile has not.

The code generated by Netbeans is of version:
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2-hudson-752-
* Generated source version: 2.2

The code generated by wscompile is of version:
// This class was generated by the JAXRPC SI, do not edit.
// Contents subject to change without notice.
// JAX-RPC Standard Implementation (1.1.2, build R23)
// Generated source version: 1.1.2



The restriction with me is that I have to stick to 1.4, as the production environment has jvm 1.4

Regards
Yogesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NullPointerException when calling a web service