轴 1.4:无法使 SOAP 请求正常工作
我真的很难让我的第一个 AXIS SOAP 客户端正常工作。 我正在使用轴 v1.4。
我们的 WSDL 包含以下内容:
....
<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>
....
我已运行 wsdl2java 来生成代码。
--
我正在初始化端口:
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://<removed>";
MyServicePort myServicePort = myService.getMyServiceSOAPPort(myServiceUrl);
--
我第一次尝试访问请求:
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);
这会导致 NullPointerException(在客户端),即使所有 null 参数都是可选的。
--
我的第二次尝试:
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());
这不会导致异常,但向 allEntries 返回 null 值,并且我不知道 SOAP 请求是否实际发送(很可能没有)。
该代码在 Oracle AS 之上运行。 在这两种情况下,即使所有不同的调试类已在 Oracle 中激活并且 LoggingHandler 已初始化,Axis 也不会将一行调试信息写入日志。
我在这里做错了什么?
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://<removed>";
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,如果参数是holder类型(即它的类是*Holder),则需要创建一个holder实例并将其作为参数值,即使该参数是可选的。 否则,您将在生成的存根类中得到空指针异常。 只是不要将任何东西放入支架内。
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.