tags:

views:

459

answers:

1

I'm really struggling to get my first AXIS SOAP client to work. I'm using Axis v1.4.

Our WSDL contains this:

....
<element name="GetParameters">
  <complexType>
    <sequence>
      <element name="param1" type="codeapi:SomeParam"/>
      <element name="param2" type="unsignedShort" minOccurs="0"/>
      <element name="param3" type="string" minOccurs="0"/>
      <element name="param4" type="unsignedShort" minOccurs="0"/>
      <element name="param5" type="unsignedShort" minOccurs="0"/>
      <element name="param6" type="string" minOccurs="0"/>
      <element name="param7" type="string" minOccurs="0"/>
      <element name="param8" type="string" minOccurs="0"/>
      <element name="param9" type="codeapi:AnotherParam" minOccurs="0"/>
    </sequence>
  </complexType>
</element>
....

I have ran wsdl2java to generate the code.

--

I'm initializing the port:

SimpleProvider conf = new SimpleProvider(new BasicClientConfig());
conf.setGlobalRequest(new LoggingHandler(LOG, Level.FINE,
    "Request sent:\n"));
conf.setGlobalResponse(new LoggingHandler(LOG, Level.FINE,
    "Response received:\n"));

MyService = new MyServiceLocator(conf);

URL myServiceURL = "http://&lt;removed&gt;";

MyServicePort myServicePort = myService.getMyServiceSOAPPort(myServiceUrl);

--

My first attempt the access the request:

SomeParam param1 = new SomeParam();
param1.setParamA("blah"); // this is the only needed parameter

Entry[] allEntries = myServicePort.getParameters(param1, null, null, null, null, null, null, null, null);

This results in NullPointerException (in the client side), even though all the null parameters are optional.

--

My second attempt:

SomeParam param1 = new SomeParam();
param1.setParamA("blah");

Entry[] allEntries = myServicePort.listCodes(param1, new UnsignedShort(), new StringHolder(), new UnsignedShort(), new UnsignedShort(), new String(), new String(), new String(), new AnotherParam());

This results in no exception, but null value returned to allEntries, and I have no idea whether a SOAP request was actually sent (most probably not).

The code is running on top of Oracle AS. In either one of the cases not a single line of debug information is written to the log by Axis, even though all the different debug classes have been activated in Oracle, and LoggingHandlers have been initialized.

What am I doing wrong here?

+1  A: 

Apparently if a parameter is of a holder type (i.e. its class is *Holder), you need to create a holder instance and give it as a parameter value, even if the parameter is optional. Otherwise you'll get a null pointer exception in the generated stub class. Just don't put anything inside the holder.

jarnoan
That seems to be the case. Thanks!
tputkonen