Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何测试webservice/WSDL_Java_Xml_Web Services_Wsdl - Fatal编程技术网

Java 如何测试webservice/WSDL

Java 如何测试webservice/WSDL,java,xml,web-services,wsdl,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="MathServi

我已经生成了这个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>
如何使用WSDL测试此Web服务是否正常工作?我不明白int1+int2和float1*float2是如何转换成XML的。我在WSDL中看到的只是转换为方法名和参数名的内容。我看不出数学是怎么回事/



也就是说,当使用webservice时,参数从何而来?你是如何使用Web服务的?我可以通过浏览器使用它吗?

对于soap,您可以使用SoapUI。请参阅。

有关soap,您可以使用SoapUI。请参阅。

您可以使用测试WSDL。

您可以使用测试WSDL。

您在WSDL中看不到数学,因为没有数学。它只是所有函数、参数和返回类型的正式声明。在后端计算的仍然是Java代码,那么参数是如何传递给代码的呢?显然,您没有直接调用方法和传递参数;它们从何而来?WSDL将告诉我之前所说的一切,以及具体的绑定,即在HTTP的情况下,要调用的URL和方法,以及传递参数的位置。我不是想回答你的问题,这只是一个关于WSDL的注释,因为你说你在那里寻找代码。你看不到WSDL中的数学,因为没有。它只是所有函数、参数和返回类型的正式声明。在后端计算的仍然是Java代码,那么参数是如何传递给代码的呢?显然,您没有直接调用方法和传递参数;它们从何而来?WSDL将告诉我之前所说的一切,以及具体的绑定,即在HTTP的情况下,要调用的URL和方法,以及传递参数的位置。我不是想回答你的问题,这只是一个关于WSDL的说明,因为你说你在那里寻找代码。例如,有很多参考资料。我应该使用什么作为服务端点?这就是我感到困惑的地方。SOAP-UI的一般说明:它不会根据wsdl自动验证输入或输出,因此有可能发送和接收不符合wsdl的xml。这正是您不应该只提供链接的原因。链接腐烂导致“入门”链接完全无用。@Volodya的人可以花点力气找出链接已经移动到哪里,你不认为吗?有很多参考资料,例如,请参阅。我应该在服务端点上使用什么?这就是我感到困惑的地方。SOAP-UI的一般说明:它不会根据wsdl自动验证输入或输出,因此有可能发送和接收不符合wsdl的xml。这正是您不应该只提供链接的原因。链接腐烂导致“入门”链接完全无用。@Volodya的人可以花点力气找出链接已经移动到哪里,你不这么认为吗?
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;
    }
}