简体   繁体   中英

How to test a webservice / WSDL

I have generated this WSDL file...

<?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>

from this class...

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;
    }
}

How can I test to see if this webservice is working properly using the WSDL? I don't understand how the functionality ( int1+int2 and float1*float2 ) translates to the XML. All I see in the WSDL are what translate to method names and parameter names. I don't see where the math goes on. :/

That said, where do the parameters come from when using the webservice? How do you even use the webservice? Can I just use it through my browser?

For soap you can use SoapUI. See http://www.soapui.org/ .

您可以使用SoapUI测试WSDL。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM