如何测试Web服务/ WSDL

时间:2011-10-24 05:35:32

标签: java xml web-services wsdl

我已经生成了这个WSDL文件......

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
<definitions targetNamespace="http://math/" name="MathServicesService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://math/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
  <types>
    <xsd:schema>
      <xsd:import namespace="http://math/" schemaLocation="MathServicesService_schema1.xsd"/>
    </xsd:schema>
  </types>
  <message name="addTwoInts">
    <part name="parameters" element="tns:addTwoInts"/>
  </message>
  <message name="addTwoIntsResponse">
    <part name="parameters" element="tns:addTwoIntsResponse"/>
  </message>
  <message name="multiplyTwoFloats">
    <part name="parameters" element="tns:multiplyTwoFloats"/>
  </message>
  <message name="multiplyTwoFloatsResponse">
    <part name="parameters" element="tns:multiplyTwoFloatsResponse"/>
  </message>
  <portType name="MathServices">
    <operation name="addTwoInts">
      <input message="tns:addTwoInts"/>
      <output message="tns:addTwoIntsResponse"/>
    </operation>
    <operation name="multiplyTwoFloats">
      <input message="tns:multiplyTwoFloats"/>
      <output message="tns:multiplyTwoFloatsResponse"/>
    </operation>
  </portType>
  <binding name="MathServicesPortBinding" type="tns:MathServices">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <operation name="addTwoInts">
      <soap:operation soapAction=""/>
      <input>
        <soap:body use="literal"/>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
    </operation>
    <operation name="multiplyTwoFloats">
      <soap:operation soapAction=""/>
      <input>
        <soap:body use="literal"/>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
    </operation>
  </binding>
  <service name="MathServicesService">
    <port name="MathServicesPort" binding="tns:MathServicesPortBinding">
      <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
    </port>
  </service>
</definitions>

来自这个班级......

package math;

import javax.jws.WebService;

@WebService
public class MathServices {

    public int addTwoInts(int int1, int int2){
        return int1+int2;
    }

    public float multiplyTwoFloats(float float1, float float2){
        return float1 * float2;
    }
}

如何使用WSDL测试此Web服务是否正常工作?我不明白功能(int1+int2float1*float2)如何转换为XML。我在WSDL中看到的只是转换为方法名称和参数名称的内容。我没看到数学在哪里。 :/

那就是说,使用网络服务时参数来自哪里?你如何使用网络服务?我可以通过浏览器使用它吗?

2 个答案:

答案 0 :(得分:3)

对于肥皂,您可以使用SoapUI。请参阅http://www.soapui.org/

答案 1 :(得分:1)

您可以使用SoapUI测试WSDL。