我将axis2用于我的网络服务。今天,当我尝试使用我自己的 wsdl 文件而不是默认生成的axis2 时,我观察到了意外的行为。这里有详细信息。
这是原始 wsdl 文件的一部分。
<xs:element name="multiply">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="a" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="b" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="c" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
I changed <xs:sequence> to <xs:all> so that i can send elements in any order in soap request.Below is the changed one.
<xs:element name="multiply">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" name="a" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="b" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="c" nillable="true" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>
当我执行这个时,我得到 a is black 和 b 和 c null 的值。
这是我发送<axis:multiply>
<axis:a>a</axis:a>
<axis:b>b</axis:b>
<axis:c>c</axis:c>
</axis:multiply>
到服务器的肥皂请求。
这是我在服务器端使用的代码片段
public String multiply(String a, String b, String c) throws Exception
{
LogHelper.info(logger, "Begin - Multiply");
if (a.trim().equals(""))
LogHelper.info(logger, "value fo a is a=\"\"");
if (b == null)
LogHelper.info(logger, "value fo b is null");
if (c == null)
LogHelper.info(logger, "value fo c is null");
return "Hellow World";
}
在记录仪的控制台上,我的输出低于:
19:47:20,227 INFO [STDOUT] INFO [SampleWebService] Begin - Multiply
19:47:20,227 INFO [STDOUT] INFO [SampleWebService] value fo a is a=""
19:47:20,227 INFO [STDOUT] INFO [SampleWebService] value fo b is null
19:47:20,228 INFO [STDOUT] INFO [SampleWebService] value fo c is null
任何人都可以告诉我为什么我收到黑色或空值,即使我正在提供值。
谢谢,
纳伦德拉