AXIS2中的Web服务方法接收空参数。为什么?

时间:2011-01-16 13:26:41

标签: java web-services axis2

我是java网络服务的新手。在尝试基本的Web服务操作时,我遇到了困难。我一直在关注这个article作为参考。服务类很简单,看起来像这样:

public class MyService {
  public MyService() {
  }
  public Boolean Configure(String param, String val){
    System.out.println("First arg: " + param + " Second arg:" + val); //Added by me.
    return true;
  }
  public Boolean StartMe(){
    return true;
  }
  public Boolean StopMe(){
    return true;
 }
 public String getStatus(){
   return "No status available!";
 }
}

我已经使用Eclipse(Bottom up Java bean Web Service)创建了服务 在那篇文章上。为了测试我的服务,我使用了Eclipse Web服务资源管理器

现在问题来了。当我在服务资源管理器中设置param值并点击go时,我会看到在控制台中打印空值( First arg:null Second arg:null )。我试图解决这个问题好几个小时但仍然没有运气。但其他三种方法没有问题。他们正在回复,我可以在服务浏览器中看到它。生成的WSDL是:

<wsdl:definitions targetNamespace="http://service.myapp.com">
<wsdl:documentation>
    Please Type your service description here
</wsdl:documentation>
<wsdl:types>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.myapp.com">
        <xs:element name="Configure">
            <xs:complexType>
                <xs:sequence>
                    <xs:element minOccurs="0" name="param" nillable="true" type="xs:string"/><xs:element minOccurs="0" name="val" nillable="true" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
        <xs:element name="ConfigureResponse">
            <xs:complexType>
                <xs:sequence>
                    <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
        <xs:element name="StartMeResponse">
            <xs:complexType>
                <xs:sequence>
                    <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
        <xs:element name="StopMeResponse">
            <xs:complexType>
                <xs:sequence>
                    <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
        <xs:element name="getStatusResponse">
            <xs:complexType>
                <xs:sequence>
                    <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:schema>
</wsdl:types><wsdl:message name="StartMeRequest"/>
<wsdl:message name="StartMeResponse">
    <wsdl:part name="parameters" element="ns:StartMeResponse"/>
</wsdl:message>
<wsdl:message name="ConfigureRequest">
    <wsdl:part name="parameters" element="ns:Configure"/>
</wsdl:message>
<wsdl:message name="ConfigureResponse">
    <wsdl:part name="parameters" element="ns:ConfigureResponse"/>
</wsdl:message><wsdl:message name="getStatusRequest"/>
<wsdl:message name="getStatusResponse">
    <wsdl:part name="parameters" element="ns:getStatusResponse"/>
</wsdl:message><wsdl:message name="StopMeRequest"/>
<wsdl:message name="StopMeResponse">
    <wsdl:part name="parameters" element="ns:StopMeResponse"/>
</wsdl:message>
<wsdl:portType name="MyServicePortType">
    <wsdl:operation name="StartMe">
        <wsdl:input message="ns:StartMeRequest" wsaw:Action="urn:StartMe"/><wsdl:output message="ns:StartMeResponse" wsaw:Action="urn:StartMeResponse"/>
    </wsdl:operation>
    <wsdl:operation name="Configure">
        <wsdl:input message="ns:ConfigureRequest" wsaw:Action="urn:Configure"/><wsdl:output message="ns:ConfigureResponse" wsaw:Action="urn:ConfigureResponse"/>
    </wsdl:operation>
    <wsdl:operation name="getStatus">
        <wsdl:input message="ns:getStatusRequest" wsaw:Action="urn:getStatus"/><wsdl:output message="ns:getStatusResponse" wsaw:Action="urn:getStatusResponse"/>
    </wsdl:operation>
    <wsdl:operation name="StopMe">
        <wsdl:input message="ns:StopMeRequest" wsaw:Action="urn:StopMe"/><wsdl:output message="ns:StopMeResponse" wsaw:Action="urn:StopMeResponse"/>
    </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MyServiceSoap11Binding" type="ns:MyServicePortType">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <wsdl:operation name="StartMe">
        <soap:operation soapAction="urn:StartMe" style="document"/>
        <wsdl:input>
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="Configure">
        <soap:operation soapAction="urn:Configure" style="document"/>
        <wsdl:input>
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getStatus">
        <soap:operation soapAction="urn:getStatus" style="document"/>
        <wsdl:input>
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="StopMe">
        <soap:operation soapAction="urn:StopMe" style="document"/>
        <wsdl:input>
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:binding name="MyServiceSoap12Binding" type="ns:MyServicePortType">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <wsdl:operation name="StartMe">
        <soap12:operation soapAction="urn:StartMe" style="document"/>
        <wsdl:input>
            <soap12:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap12:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="Configure">
        <soap12:operation soapAction="urn:Configure" style="document"/>
        <wsdl:input>
            <soap12:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap12:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getStatus">
        <soap12:operation soapAction="urn:getStatus" style="document"/>
        <wsdl:input>
            <soap12:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap12:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="StopMe">
        <soap12:operation soapAction="urn:StopMe" style="document"/>
        <wsdl:input>
            <soap12:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap12:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:binding name="MyServiceHttpBinding" type="ns:MyServicePortType">
    <http:binding verb="POST"/>
    <wsdl:operation name="StartMe">
        <http:operation location="MyService/StartMe"/>
        <wsdl:input>
            <mime:content type="text/xml" part="StartMe"/>
        </wsdl:input>
        <wsdl:output>
            <mime:content type="text/xml" part="StartMe"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="Configure">
        <http:operation location="MyService/Configure"/>
        <wsdl:input>
            <mime:content type="text/xml" part="Configure"/>
        </wsdl:input>
        <wsdl:output>
            <mime:content type="text/xml" part="Configure"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getStatus">
        <http:operation location="MyService/getStatus"/>
        <wsdl:input>
            <mime:content type="text/xml" part="getStatus"/>
        </wsdl:input>
        <wsdl:output>
            <mime:content type="text/xml" part="getStatus"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="StopMe">
        <http:operation location="MyService/StopMe"/>
        <wsdl:input>
            <mime:content type="text/xml" part="StopMe"/>
        </wsdl:input>
        <wsdl:output>
            <mime:content type="text/xml" part="StopMe"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:service name="MyService">
    <wsdl:port name="MyServiceHttpSoap11Endpoint" binding="ns:MyServiceSoap11Binding">
        <soap:address location="http://110.227.162.237:8080/WebServicePrototype/services/MyService.MyServiceHttpSoap11Endpoint/"/>
    </wsdl:port>
    <wsdl:port name="MyServiceHttpSoap12Endpoint" binding="ns:MyServiceSoap12Binding">
        <soap12:address location="http://110.227.162.237:8080/WebServicePrototype/services/MyService.MyServiceHttpSoap12Endpoint/"/>
    </wsdl:port>
    <wsdl:port name="MyServiceHttpEndpoint" binding="ns:MyServiceHttpBinding">
        <http:address location="http://110.227.162.237:8080/WebServicePrototype/services/MyService.MyServiceHttpEndpoint/"/>
    </wsdl:port>
</wsdl:service>

我正在使用:a)Eclipse:Ganymede / Galileo             b)Tomcat 6.0             c)AXIS2 1.4.1

请帮帮我或让我知道我是否缺少一些基本的基础知识。任何帮助深表感谢。

0 个答案:

没有答案