0

我将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

任何人都可以告诉我为什么我收到黑色或空值,即使我正在提供值。

谢谢,
纳伦德拉

4

1 回答 1

0

这是亚行的一个错误。请参考https://issues.apache.org/jira/browse/AXIS2-842

它已被修复,所以我猜您使用的是旧版本。

我已经用轴 1.5.1/jdk1.6.0/openSuse 11.2 测试了这个问题。它似乎与 REST 调用和客户端存根一起工作顺利。这是我的复杂类型:

<xsd:element name="concat">
  <xsd:complexType>
    <xsd:all>
        <xsd:element name="s1" type="xsd:string"/>
        <xsd:element name="s2" type="xsd:string"/>
   </xsd:all>
 </xsd:complexType>
</xsd:element>

该操作应该连接到字符串。REST URL 如下所示:

http://.../axis2/services/TestService/concat?s2=test2&s1=test1

响应似乎也可以:

<ns1:concatResponse xmlns:ns1="..."><r>test1test2</r></ns1:concatResponse>

服务实现是微不足道的。所以......它对我来说是固定的:-(

干杯!

于 2010-12-04T08:03:46.653 回答