我一直在尝试使用eclipse,Tomcat 8和Axis来实现的一个相当复杂的Web服务遇到各种问题。这是我第一次使用Web服务,因此我决定开始搞一些更简单的事情,以确保我知道自己在做什么。这是我目前用来在eclipse中从中生成服务的WSDL。
_onSelectAllChanged
该WSDL不是我自己的,并且取自tutorial。我并不严格遵循本教程,因为Axis使用wsdl2java而不是wsimport进行代码生成,而我让eclipse / Axis处理web.xml。
我可以成功生成Web服务,并且使用eclipse的Web Service的资源管理器进行测试可以正常工作。我的问题是,我想使用生成的客户端对此进行测试,而不是仅在本地对Web服务进行测试。我生成了Web服务客户端,并在客户端内部编写了一个非常简单的程序来尝试对其进行测试。
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.example.org/WeatherService/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="WeatherService"
targetNamespace="http://www.example.org/WeatherService/">
<wsdl:types>
<xsd:schema targetNamespace="http://www.example.org/WeatherService/">
<xsd:element name="getcurrentTemperatureRq">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="city" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getcurrentTemperatureRs">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="temperature" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getcurrentTemperatureRq">
<wsdl:part element="tns:getcurrentTemperatureRq" name="parameters"/>
</wsdl:message>
<wsdl:message name="getcurrentTemperatureRs">
<wsdl:part element="tns:getcurrentTemperatureRs" name="parameters"/>
</wsdl:message>
<wsdl:portType name="WeatherServicePortType">
<wsdl:operation name="getcurrentTemperature">
<wsdl:input message="tns:getcurrentTemperatureRq"/>
<wsdl:output message="tns:getcurrentTemperatureRs"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WeatherServiceSOAP" type="tns:WeatherServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getcurrentTemperature">
<soap:operation soapaction="http://www.example.org/WeatherService/getcurrentTemperature"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WeatherService">
<wsdl:port binding="tns:WeatherServiceSOAP" name="WeatherServiceSOAP">
<soap:address location="http://localhost:80/WeatherServiceApp/WeatherService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
运行此命令时出现错误。
package client;
import java.rmi.RemoteException;
import org.example.www.WeatherService.*;
public class WeatherServiceclient {
public static void main(String [] args) throws RemoteException {
WeatherServiceSOAPStub stub = new WeatherServiceSOAPStub();
getcurrentTemperatureRq rq = new getcurrentTemperatureRq();
stub.getcurrentTemperature(rq);
}
}
尝试此操作时,主要的Web服务正在Tomcat中运行。
如何解决此端点问题?我的WSDL中的地址是否有问题,或者是否需要更改soapaction?