SOAP Web服务:根据逻辑返回不同的响应

我已经在eclipse中创建了Java SOAP Web服务。我希望能够根据输入返回不同的响应。用户输入姓名,年龄,ID。如果年龄大于20岁,则响应如下:

         <name>Yeah</name>
         <id>99</id>
         <age>89</age>

如果年龄小于20岁,则响应如下:

         <responseCode>ERROR</responseCode>
         <responseMessage>YOU ARE NOT ELIGIBLE FOR THIS SERVICE</responseMessage>

现在,我能够实现第一种情况。如何以相同的方法实现第二个目标? 以下是我的WSDL

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://personally" xmlns:intf="http://personally" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://personally">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22,2006 (06:55:48 PDT)-->
 <wsdl:types>
  <schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://personally">
   <element name="getPerson">
    <complexType>
     <sequence>
      <element name="name" type="xsd:string"/>
      <element name="id" type="xsd:string"/>
      <element name="age" type="xsd:string"/>
     </sequence>
    </complexType>
   </element>
   <element name="getPersonResponse">
    <complexType>
     <sequence>
      <element name="name" type="xsd:string"/>
      <element name="id" type="xsd:string"/>
      <element name="age" type="xsd:string"/>
     </sequence>
    </complexType>
   </element>
  </schema>
 </wsdl:types>

   <wsdl:message name="getPersonRequest">

      <wsdl:part element="impl:getPerson" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:message name="getPersonResponse">

      <wsdl:part element="impl:getPersonResponse" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:portType name="PersonServ">

      <wsdl:operation name="getPerson">

         <wsdl:input message="impl:getPersonRequest" name="getPersonRequest">

       </wsdl:input>

         <wsdl:output message="impl:getPersonResponse" name="getPersonResponse">

       </wsdl:output>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="PersonServSoapBinding" type="impl:PersonServ">

      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="getPerson">

         <wsdlsoap:operation soapaction=""/>

         <wsdl:input name="getPersonRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="getPersonResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="PersonServService">

      <wsdl:port binding="impl:PersonServSoapBinding" name="PersonServ">

         <wsdlsoap:address location="http://localhost:8080/PersonProject/services/PersonServ"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>

以下是我的实现:

/**
 * PersonServSoapBindingImpl.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis 1.4 Apr 22,2006 (06:55:48 PDT) WSDL2Java emitter.
 */

package personally;

public class PersonServSoapBindingImpl implements personally.PersonServ {
    public void getPerson(javax.xml.rpc.holders.StringHolder name,javax.xml.rpc.holders.StringHolder id,javax.xml.rpc.holders.StringHolder age) throws java.rmi.RemoteException {

    }

}
zcshou 回答:SOAP Web服务:根据逻辑返回不同的响应

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3035540.html

大家都在问