使用Stub调用Web服务

时间:2013-08-28 14:48:21

标签: java web-services axis2

你能帮我找出正确的方法来调用webservice,下面是wsdl文件

Eclipse生成以下类:

EmpLookup 
EmpLookupLocator
EmpLookupPort 
EmpLookupPortProxy
EmpLookupPortStub
EmpLookupRequest
EmpLookupResponse

的wsdl:

<xsd:complexType     name="List">
    <xsd:sequence>
     <xsd:element       maxOccurs="unbounded"
       nillable="true"
       name="anyType"
       type="xsd:anyType"
       minOccurs="0">
     </xsd:element>
    </xsd:sequence>
   </xsd:complexType>
  </xsd:schema>
  <xsd:schema    xmlns:stns="java:com.test.ws.emp"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    attributeFormDefault="qualified"
    targetNamespace="java:com.test.ws.emp"
    elementFormDefault="qualified">
   <xsd:complexType     name="EMPLookupRequest">
    <xsd:sequence>
     <xsd:element       maxOccurs="1"
       nillable="true"
       name="empName"
       type="xsd:string"
       minOccurs="1">
     </xsd:element>
     </xsd:element>
    </xsd:sequence>
   </xsd:complexType>
  </xsd:schema>
  <xsd:schema    xmlns:stns="https://test/empLookup"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    attributeFormDefault="unqualified"
    targetNamespace="https://test/empLookup"
    elementFormDefault="qualified">
   <xsd:import     namespace="java:language_builtins.util">
   </xsd:import>
   <xsd:import     namespace="java:com.test.ws.emp">
   </xsd:import>
   <xsd:element     name="lookupEmp">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element        xmlns:tp="java:com.test.ws.emp"
        name="empLookupRequest"
        type="tp:EMPLookupRequest">
      </xsd:element>
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
   <xsd:element     name="lookupEmpResponse">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element        xmlns:tp="java:language_builtins.util"
        name="result"
        type="tp:List">
      </xsd:element>
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
  </xsd:schema>
 </types>
 <message   name="lookupEmp">
  <part    xmlns:partns="https://test/empLookup"
    element="partns:lookupEmp"
    name="parameters">
  </part>
 </message>
 <message   name="lookupEmpResponse">
  <part    xmlns:partns="https://test/empLookup"
    element="partns:lookupEmpResponse"
    name="parameters">
  </part>
 </message>
 <portType   name="empLookupPort">
  <operation    name="lookupEmp">
   <input     message="tns:lookupEmp">
   </input>
   <output     message="tns:lookupEmpResponse">
   </output>
  </operation>
 </portType>
 <binding   name="empLookupPort"
   type="tns:empLookupPort">
   <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
  <operation    name="lookupEmp">
    <soap:operation style="document" soapAction="" />
   <input>
     <soap:body use="literal" />
   </input>
   <output>
     <soap:body use="literal" />
   </output>
  </operation>
 </binding>
 <service   name="empLookup">
  <port    name="empLookupPort"
    binding="tns:empLookupPort">
    <soap:address location="http://localhost:8080/empLookup/empLookup" />
  </port>
 </service>

如何编写samll类来拨打电话并获得回复?根本不知道。

1 个答案:

答案 0 :(得分:0)

你可以参考phpeveryday 它可能解决您的问题 http://www.phpeveryday.com/articles/Web-Services-WSDL-Creating-SOAP-Server-P484.html